M
M
Mike Diam2017-05-13 15:59:16
Nginx
Mike Diam, 2017-05-13 15:59:16

How to open nodejs applications on nginx server?

The node js application uses the express() server and runs on port 3000. If you execute curl localhost:3000 in the console, Hello Wold!
But if you try to remotely open the application at ip_server address: 3000, then nothing will come in response - ERR_CONNECTION_REFUSED
config:

upstream app {
  server localhost:3000;
}
server {

    listen 80;

    access_log /var/log/nginx/proxy-access.log;
    error_log /var/log/nginx/proxy-error.log;

    location / {
      proxy_pass http://ip_сервера:3000/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mike Diam, 2017-05-13
@mikediam

listen 3000

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question