Nginx子域没有路由到Node.js

我有一个我想通过Nginx代理到Node.js的子域

domain.tld目前是通过/opt/nginx/conf/nginx.conf路由的标准方式。

但是,我也想要subdomain.domain.tld路由到domain.tld:8000

为此,我将以下内容放在/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似乎启动正常。 子域的名称服务器configuration正确。

我究竟做错了什么? 预先感谢任何帮助。

编辑:另外,我将文件从sites-available/sites-enabled/

编辑: /opt/nginx/conf/nginx.conf的确切内容:

http://pastebin.com/wZJFPx7H

编辑:从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() 

首先,检查启动过程中日志中是否有错误。

它可能没有加载这个服务器,因为这个:

 proxy_pass 127.0.0.1:8000; 

应该改为:

 proxy_pass http://127.0.0.1:8000; 

除此之外,将listen指令与其他server块中的指令进行比较 – 确保匹配。 如果他们绑定到一个特定的地址,而不是0.0.0.0,那么这个server将不会得到请求。

编辑

对于那些将来会发现这个问题的人来说,子域的server块并没有被包含在内,并且include块必须位于现有的http块中,以避免地址绑定冲突。