genshen / ssh-web-console

Connect to your linux machine via ssh in your browser.
MIT License
331 stars 70 forks source link

Disconnected from Remote host #24

Open icvdok opened 4 months ago

icvdok commented 4 months ago

Hi, It works fine within the internal network. Configuring nginx proxy manager exposing an https url, the webgui is accessible, it connect to the server via SSH but it disconnect immediately.

Message error:

2024/05/07 18:56:39 http: superfluous response.WriteHeader call from github.com/genshen/ssh-web-console/src/controllers.(*SSHWebSocketHandle).ServeAfterAuthenticated (websocket.go:38) 2024/05/07 18:56:39 Error: Cannot setup WebSocket connection: failed to accept WebSocket connection: WebSocket protocol violation: Connection header "close" does not contain Upgrade

There is something wrong in my nginx proxy manager config or it's something on the ssh-web-console docker?

Thanks for the support

1Hmamir commented 4 months ago

I have the same problem, how can I try to solve this?

genshen commented 4 months ago

Have you add proxy_set_header Connection "upgrade" to your nginx config?
Here is my nginx config (with https enabled).

server {
       listen         80;
       listen [::]:80;
       server_name    example.com;
       return         301 https://$http_host$request_uri;
}

server {
    listen       443 ssl;
    listen     [::]:443 ssl;
    server_name  example.com;
    access_log   logs/example.com.log;
    ssl_certificate      ../sslcrt/example.com.crt;
    ssl_certificate_key  ../sslcrt/example.com.key;

    location / {
        client_max_body_size 10m;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_pass http://127.0.0.1:22222;
    }
}