I\'ve set up Node.js and Nginx on my server. Now I want to use it, but, before I start there are 2 questions:
You can also setup multiple domain with nginx, forwarding to multiple node.js processes.
For example to achieve these:
These ports (4000 and 5000) should be used to listen the app requests in your app code.
/etc/nginx/sites-enabled/domain1
server {
listen 80;
listen [::]:80;
server_name domain1.com;
access_log /var/log/nginx/domain1.access.log;
location / {
proxy_pass http://127.0.0.1:4000/;
}
}
In /etc/nginx/sites-enabled/domain2
server {
listen 80;
listen [::]:80;
server_name domain2.com;
access_log /var/log/nginx/domain2.access.log;
location / {
proxy_pass http://127.0.0.1:5000/;
}
}