What is wrong with our configuration? NGINX is not adding the proper headers.
Using React front end to initialize client with wss
connection, received by AWS ELB, passed unencrypted to nginx, proxy_passed to Rails backend.
React connection url
wss://mydomain.com/ws/cable
nginx config
location /ws/ {
proxy_pass http://backend_host/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
In Rails, the ws fails here because env['HTTP_CONNECTION']
and env['HTTP_UPGRADE']
are not correctly set by nginx.
env['HTTP_CONNECTION']
should equal "Upgrade" and instead is "close"
env['HTTP_UPGRADE']
should equal "websocket" and instead is nil
What can we change in nginx to fix these headers?