I am configuring Nginx to redirect incoming web socket requests to two different servers, but every time I get 404.
My Nginx configuration in loadbalancer.conf file in /etc/nginx/conf.d/ folder look like this:
upstream websocket {
server localhost:5050; //web socket server1 running here
server localhost:8080; //web socket server2 running here
}
server {
listen 4141;
server_name localhost:4141;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header Connection "upgrade";
}
}
When I am hitting web socket servers directly (URL: ws://localhost:8080/app/socket/user1) then the request are working fine but when I am going through Nginx (URL: ws://localhost:4141/app/socket/user1) then the requests are not delivering to any of the web socket servers.
Update:
- I have tried to change the proxy_pass setting to directly the server1 (localhost:5050) then also the request is not going through.
- Nginx access log says the following error:
::1 - - [09/Jan/2023:10:57:07 +0530] "GET /app/socket/user1 HTTP/1.1" 404 197 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
Can someone please answer
- What is wrong with the configuration?
- Does Nginx provide more detailed logs, where can I check them?