I have 2 NodeJS Apps running on http://localhost:3000
and http://localhost:3001
. I am trying to get both running using Nginx reverse proxy at http://test.com
and http://api.test.com
respectively.
My Nginx version is nginx/1.18.0 (Ubuntu)
File: sites-enabled/api.test.com
server {
listen 80;
server_name api.test.com;
root /var/www/html/api;
index index.html index.htm;
location /app_api_location {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
File: sites-enabled/test.com
server {
listen 80;
server_name test.com www.test.com;
root /var/www/html/test;
index index.html index.htm;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Neither of the apps is working. There are no other files in sites-enabled. It is a new server setup with Ubuntu 22.04. I have done this a few times before and matched it to other reverse proxies running on my other servers, I can't seem to figure this out.
This was solved. Whenever using services like DigitalOcean or AWS Lightsail. UFW is entirely disabled and the control panels give access to manage(allow and disallow traffic). It was immediately resolved when I allowed port 80 HTTP traffic from the dashboard. Silly mistake.