map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 3000; listen [::]:3000; server_name _; location = / { return 302 $scheme://$http_host/ssh/host/127.0.0.1; } location = /ssh { return 302 $scheme://$http_host/ssh/host/127.0.0.1; } location = /ssh/host { return 302 $scheme://$http_host/ssh/host/127.0.0.1; } location ~ ^/ssh/host/(?!127\.0\.0\.1(?:/|$)).+ { return 302 $scheme://$http_host/ssh/host/127.0.0.1; } location / { proxy_pass http://127.0.0.1:3001; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 3600; proxy_send_timeout 3600; } }