Saturday 24 December 2016

Can't run 2 Socket.io based apps with Nginx

I have 2 Socket.io apps. The first one is running on localhost:3000 and the second is working onlocalhost:8878.What I want to do is to reverse proxy them in the way that the first one will work on localhost and the second one on localhost/myapp.This is the Nginx configuration that I'm using:server { listen 80; server_name localhost; location / { proxy_pass http://localhost:3000; } location /myapp/ { proxy_pass http://localhost:8878/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # WebSocket support (nginx 1.4) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* \.io { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://localhost:3000; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } The first one is working fine, but the other one isn't working. Ps: even changing proxy_pass http://localhost:3000; in location ~* \.io to proxy_pass http://localhost:3000; doesn't make the second app work. Can someone please help me?

Submitted December 24, 2016 at 04:49PM by tigerosh

No comments:

Post a Comment