简体   繁体   中英

Nginx pass proxy to another nodejs server

Node js part:

app.listen(4000,"localhost");

Nginx default:

  server{
    server_name "mydomain";
    location /{
    proxy_pass http://localhost:4000;
    }
    }

When i set it with localhost it's working.

When i run the node script on another server and set nginx configuration like this:

server{
    server_name "mydomain";
    location /{
    proxy_pass http://192.168.1.30:4000;
    }
    }

This is not working. I'm getting 502 Bad Gateway error when i try to connect "mydomain".

I've solved the problem with changing the node script.

app.listen(4000,"localhost"); to app.listen(4000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM