I have a subdomain that I want to proxy through Nginx to Node.js.
domain.tld
is currently routed the standard way through /opt/nginx/conf/nginx.conf
.
However, I also want subdomain.domain.tld
to route to domain.tld:8000
.
To do this, I put the following in /etc/nginx/sites-available/subdomain.domain.tld.conf
:
http{
server {
listen 0.0.0.0:80;
server_name subdomain.tld.com;
access_log /var/log/nginx/subdomain.domain.log;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
}
Nginx seems to start up fine. The subdomain's nameservers are configured correctly.
What am I doing wrong? Thanks a ton for any help in advance.
Edit: Also, I symlinked the file from sites-available/
to sites-enabled/
.
Edit: The exact contents of /opt/nginx/conf/nginx.conf
:
Edit: The error message starting nginx:
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()