I have a website that needs to work through an Nginx server. At the moment, I don't believe the configuration for nginx is correct. I currently have
server{
server_name websitename.com;
location /websocket/{
proxy_pass http://websitename.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header $host;
}
}
At the moment, I am receiving an error on the website that reads "SCRIPT12008: SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status code 200, OK", which I believe is because the protocol is not switching correctly.
You forgot the double quotes and "Host" before $host to set the Host directive:
proxy_set_header "Host" $host;So your setup would like this instead:
server{ server_name websitename.com; location /websocket/{ proxy_pass "http://websitename.com"; proxy_http_version 1.1; proxy_set_header "Upgrad"e $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } }Always check your syntax with the 'nginx -t' command.