Issue
I'm trying to set up nginx so I can have my domain, domain.com
run by a node web app on port 3000, and the subdomain dev.domain.com
run by a second node web app on port 3001. When I run this configuration domain.com
is connected to the right port, but dev.domain.com
just gives a page that says the server can't be reached.
Edit:
If I go to IP_ADDRESS:3000
I get the same content as domain.com
, but if I go to IP_ADDRESS:3001
I get what should be at dev.domain.com
. Based on this it seems like the apps are running fine on the right ports, and I'm just not routing the subdomain correctly.
Code
I edited /etc/nginx/sites-available/default
directly so it has:
server {
listen 80 default_server;
server_name domain domain.com www.domain.com;
location / {
proxy_pass http://127.0.0.1:3000;
}
}
server {
listen 80;
server_name dev.domain dev.domain.com www.dev.domain.com;
location / {
proxy_pass http://127.0.0.1:3001;
}
}
Other than that file everything else is a fresh install
My logic
I'm very new to nginx but this seems like any requests for domain.com
would get sent to port 3000, and requests for dev.domain.com
would go to 3001.
Any help or critique of what I've done so far would be greatly appreciated!