Nginx as a WebSocket Proxy giving Invalid URL Prefix error

Viewed 677

We are facing issue while configuring Nginx as a webSocket proxy in Web Application. We have added the following configuration related to websockets in nginx.conf:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream websocket {
    server 234.61.34.23:3389;
}

location /websocket-tunnel/connect/ {
        proxy_read_timeout 86400;
        proxy_redirect off;
        proxy_pass http://websocket;
        proxy_buffering off;
        proxy_http_version 1.1;
        add_header Upgrade $http_upgrade;
        add_header Connection "upgrade";
        add_header Host $host;
        add_header X-Real-IP $remote_addr;
        add_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header X-Forwarded-Server $host;    
    }

234.61.55.59:8090 - is the IP address & Port of the machine on which Nginx is installed and running.

234.61.34.23:3389 - is the IP address & port of the backend system to connect.

Now from the javascript code in Web application we are creating websocket and generating the following request URL:

wss://234.61.55.59:8090/websocket-tunnel/connect?id=12345

Now getting the following error in Nginx error.log

[error] 9516#33264: *396 invalid URL prefix in "ws://websocket/websocket-tunnel/connect?id=12345"

Is there any thing we have missing in nginx websocket configuration? Any Suggestions on resolving this error please.

0 Answers
Related