I am attempting to run two node.js applications from the same droplet, off the same url. I am serving the first app from http://finleywill.com, and would like to serve the second app from http://finleywill.com/todo.
I am running nginx on the server.
The first app, my portfolio page, listens to port 5000.
The second app, a to-do list, listens to port 8888.
/etc/nginx/sites-available/finleywill.com is as following:
server { listen 80; listen [::]:80;
root /var/www/finleywill.com/html;
index index.html index.htm index.nginx-debian.html;
server_name finleywill.com www.finleywill.com;
access_log /root/source/access.log;
error_log /root/source/error.log;
location / {
proxy_pass http://localhost:5000;
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;
}
location /todo {
proxy_pass http://localhost:8888;
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;
}
}
I use PM2 to run the apps as system processes
App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
app │ 0 │ 1.0.0 │ fork │ 27064 │ online │ 0 │ 72m │ 0% │ 55.5 MB │ root │ disabled │ app-todo │ 1 │ 1.0.0 │ fork │ 27156 │ online │ 0 │ 40m │ 0% │ 37.0 MB │ root │ disabled │
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
I figured it out with help from a friend!
…as per https://serverfault.com/questions/650117/serving-multiple-proxy-endpoints-under-location-in-nginx
I changed /etc/nginx/sites-available/finleywill.com to the following:
server { listen 80; listen [::]:80;
}
I have configured as same as above, but the page loading