Http2, Websockets and SSOwat (Cockpit)

Hi there,
I’m trying to make Cockpit (cockpit-project.org) work, with plans to propose this as a Ynh app.
Currently, I’m not able to make websockets work through Nginx.

My nginx config file is :

rewrite ^/cockpit$ /cockpit/ permanent;

location /cockpit/ {
    proxy_pass https://127.0.0.1:9090/cockpit/;

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # Required for web sockets to function
    proxy_http_version 1.1;
    proxy_buffering off;
    proxy_set_header Upgrade websocket;
    proxy_set_header Connection "Upgrade";

    # Pass ETag header from Cockpit to clients.
    # See: https://github.com/cockpit-project/cockpit/issues/5239
    gzip off;

    # Include SSOWAT user panel.
    # include conf.d/yunohost_panel.conf.inc;
}

My request url : wss://mydomain.fr/cockpit/cockpit/socket

Any clue ?

Have you look into the browser console ?

Also there’s an existing package though no idea in what state it is … https://github.com/YunoHost-Apps/cockpit_ynh/blob/master/conf/nginx.conf

Thanks for pointing out the (non-working) existing app. I should’ve read in more details the nginx conf. Looks like I was just missing one line :

proxy_set_header Origin http://$host;

Now it’s working !
I may do a PR to the existing app soon or later this week.

1 Like