node.js - Socket.io client-side javascript file location (with nginx reverse proxy) -
i'm trying run multiple nodejs apps on same server/port, using nginx reverse proxy proxies actual running node app.
server { listen 8000; server_name node.domain.com; root /var/www/node; 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; # enables ws support proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; proxy_redirect off; location / { proxy_pass http://127.0.0.1:8001; } location /irc/ { proxy_pass http://127.0.0.1:8002; } location /voidwalker/ { proxy_pass http://127.0.0.1:8003; } } as can see have different projects (nodejs apps) running (using forever) in different subdirectories of /var/www/node.
but want use socket.io in 1 of projects. , in socket.io docs states should use <script src="/socket.io/socket.io.js"></script> load socket.io-client on client side, returns 404:
get http://node.domain.com/socket.io/socket.io.js 404 (not found) i'm guessing because i'm proxying requests don't entirely understand how process works internally , love work.
something note regarding have use <link rel="stylesheet" href="/voidwalker/css/main.css"> load css, while rather use <link rel="stylesheet" href="/css/main.css"> in case want deploy on specific subdomain/other domain (since development server).
edit
so, after debugging ray stantz think there going wrong in proxy. moved socket.io.js /public/js/socket.io.js , can use isn't right solution.
if has ideas on this, i'll pleased hear them , try them out!
had same issue. resolved routing /socket.io node.js application in nginx configuration. in case should like:
server { listen 8000; server_name node.domain.com; root /var/www/node; 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; # enables ws support proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection "upgrade"; proxy_redirect off; location / { proxy_pass http://127.0.0.1:8001; } location /irc/ { proxy_pass http://127.0.0.1:8002; } location /voidwalker/ { proxy_pass http://127.0.0.1:8003; } location /socket.io { proxy_pass http://127.0.0.1:8003; } } the drawback solution voidwalker app can use socket.io (since /socket.io served on 127.0.0.1:8003).
Comments
Post a Comment