Websocket 302 (redirect) error -Chrome -Opera

NGINX server {

listen; listen ssl; root /usr/share/nginx/html; index index.html index.htm;

ssl on; ssl_certificate /etc/ssl/certs/ssl-bundle.crt; ssl_certificate_key /etc/ssl/private/budokai-online_com.key; ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kED$ ssl_dhparam /etc/ssl/private/dhparmas.pem; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

if ($ssl_protocol = "") { rewrite ^ https://$host$request_uri? permanent;

} large_client_header_buffers 8 32k; location / {

proxy_http_version 1.1;

proxy_set_header Accept-Encoding ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X_FORWARDED_PROTO https; proxy_set_header X-NginX-Proxy true; proxy_buffers 8 32k; proxy_buffer_size 64k; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_read_timeout 86400; proxy_pass ;


The problem I’m having is that some computers and some browsers are being redirected when trying to get a connection to the websocket. When that 302 error shows up, the ‘/*’ routes has been activated! This route redirects the user to the login page as you saw in the redirect response.The websocket upgrade request is turned into an ordinary http request somehow, somewhere! This seems to be where the problem is. What can be causing this?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You may need to update

if ($sslprotocol = "") {
rewrite ^ https://$host$requesturi? permanent;


to this

if ($https = "") {
rewrite ^ https://$host$requesturi? permanent;


I haven’t seen the use of $sslprotocol before in this context and wasn’t able to find anything through a google search.