I cannot connect to my Socket IO server after uploading and configuring on the server. It is giving 400 error:
My server: Rocket Linux. Using Nginx. Socket Io server was written in Python. In my localhost it is working perfectly. However, on the server which I should configure it is giving above error. Even, I configured on different server with same Nginx configuration, it was successfully connected. My Nginx config:
server {
listen 5000 ssl;
server_name e-buyurtma.ecdn.uz www.e-buyurtma.ecdn.uz;
access_log /var/log/nginx/ws-server-access.log;
error_log /var/log/nginx/ws-server-error.log;
location ^~/socket.io {
proxy_pass http://127.0.0.1:3675;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
ssl_certificate hidden;
ssl_certificate_key hidden;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_ciphers hidden;
ssl_prefer_server_ciphers on;
ssl_dhparam hidden;
ssl_session_timeout 5m;
}
The problem was solved! There was one proxy Ubuntu server behind the server I run my websocket server. In that proxy Ubuntu server, redirection to my server was done by Nginx. We have added socket IO's header configs to that proxy server's Nginx, then my requests worked successfully.
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}