Skip to content

Behind a gateway nginx proxy, Error during WebSocket handshake: Unexpected response code: 404  #231

Open
@lan10rd

Description

@lan10rd

I am trying to deploy this behind a reverse proxy (nginx), and i have other examples of my apis using socket.io that work when upgraded to wss, but for some reason i am seeing:

Error during WebSocket handshake: Unexpected response code: 404

on the webshockify call.

I am forcing all http traffic to be upgraded to https and i see everything working except for this wss://mydomain/webshockify call, here is my configuration so far:

server {
client_body_timeout 10m;
client_header_timeout 10m;
client_max_body_size 1000000M;
large_client_header_buffers 8 32k;
listen 443 ssl http2;
listen [::]:443 ssl http2;
send_timeout 10m;
server_name face.ocelot.work;
ssl_certificate /etc/letsencrypt/live/XX/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/XX/privkey.pem;
fastcgi_buffer_size 256k;
fastcgi_buffers 8 128k;
fastcgi_read_timeout 300s;
add_header X-Frame-Options "";
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
# proxy_set_header Proxy ""; # to mitigate httpoxy attack

location /webshockify/ {
    proxy_pass $upstream;
    set $upstream http://XX_container:80;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;

    # enable sticky session based on IP
    # ip_hash;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
}
location / {
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    proxy_pass $upstream;
    proxy_set_header   Host $host;
    set $upstream http://XX_container:80;
    proxy_ssl_server_name on;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions