Nginx - 映射子域

时间:2015-03-16 06:11:20

标签: nginx digital-ocean

我正在尝试在我的digitalocean droplet上设置一个子域,该子域映射到静态html文件。目前,我的nginx .conf文件如下所示:

server{
    listen 80;
    server_name example.com www.example.com;
    location / {
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        Host $http_host;
            proxy_pass              http://127.0.0.1:4000;
    }
}

server{
    listen 80;
    server_name subdomain.example.com;
    location / {
            root    /var/www/subdomain-dir;
            index   index.html;
    }
}

在example.com上,我在端口4000上运行节点服务器,一切都很好。在subdomain.example.com上,我只想提供位于/var/www/subdomain路径中的静态html文件。那部分不起作用。我已经验证文件和文件路径是正确的,我重新启动了nginx服务器。我想知道这个问题是否可能与端口有关,但是,最后,我只是输了什么问题。当我浏览subdomain.example.com时,它会显示This webpage is not available

UPDATE /修改

这是access.log和error.log:

==> access.log.1 <==
180.76.4.226 - - [14/Mar/2015:19:17:31 -0400] "GET / HTTP/1.1" 200 612 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
180.76.4.135 - - [14/Mar/2015:21:18:35 -0400] "GET / HTTP/1.1" 200 612 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
149.129.42.215 - - [14/Mar/2015:21:19:51 -0400] "GET /tmUnblock.cgi HTTP/1.1" 400 181 "-" "-"
180.76.4.19 - - [14/Mar/2015:23:26:26 -0400] "GET / HTTP/1.1" 200 12805 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
207.46.13.126 - - [15/Mar/2015:01:06:39 -0400] "GET /robots.txt HTTP/1.1" 404 177 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
207.46.13.126 - - [15/Mar/2015:01:06:43 -0400] "GET /capture.php HTTP/1.1" 404 151 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"
180.76.4.9 - - [15/Mar/2015:01:19:23 -0400] "GET / HTTP/1.1" 200 612 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
38.100.21.67 - - [15/Mar/2015:02:57:22 -0400] "GET / HTTP/1.1" 200 612 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)"
180.76.4.156 - - [15/Mar/2015:03:18:33 -0400] "GET / HTTP/1.1" 200 612 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
180.76.4.181 - - [15/Mar/2015:05:21:35 -0400] "GET / HTTP/1.1" 200 612 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"

==> error.log.1 <==
2015/03/10 18:16:42 [emerg] 29461#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:16:42 [emerg] 29461#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:16:42 [emerg] 29461#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:16:42 [emerg] 29461#0: still could not bind()
2015/03/10 18:17:01 [emerg] 29499#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:17:01 [emerg] 29499#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:17:01 [emerg] 29499#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:17:01 [emerg] 29499#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:17:01 [emerg] 29499#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2015/03/10 18:17:01 [emerg] 29499#0: still could not bind()

0 个答案:

没有答案