Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question