nginx:配置文件/etc/nginx/nginx.conf测试失败(上游找不到主机)

时间:2014-10-27 10:30:04

标签: nginx vagrant

我有一个流浪的盒子,一段时间以来一直工作正常,今天由于某些原因,当我尝试重新启动nginx时,我得到以下内容。

nginx: [emerg] host not found in upstream "www.myclass.com.192.168.33.10.xip.io" in /etc/nginx/conf.d/myclass.com.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed

据我所知,我自己没有改变任何内容(除非Windows Update做了一些奇怪的事情)

任何人都可以建议如何让nginx再次使用&允许我重新启动nginx服务 - 看起来我无法ping主机......任何想法为什么?

这是我的nginx conf文件: nginx conf file

- Update-- 运行以下命令检查端口80上的内容..(已阅读另一个类似的帖子),我可以看到清漆守护程序在端口80上..这是问题的原因??任何建议都会受到欢迎,因为我对这个东西不熟悉

sudo netstat -tlnp | grep 80

我的myclass.com.conf文件

server {
listen              80;
server_name         class.com.* www.class.com.*;

root /vagrant/www.class.com/public_html;
index index.php;

access_log /vagrant/log/class.com.access.log;
error_log  /vagrant/log/class.com.error.log error;

charset utf-8;

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt  { access_log off; log_not_found off; }

error_page 404 /index.php;

location /socket.io {
    proxy_pass http://www.class.com.192.168.33.10.xip.io:8055;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;
}

location / {
    try_files       $uri $uri/ @handler;
    expires         30d;
}

location  /. {
    return 404;
}

location @handler {
    rewrite / /index.php last;
}

location ~ .php/ {
    rewrite ^(.*.php)/ $1 last;
}

location ~ \.php$ {
    try_files                       $uri =404;

    expires                         off;

    fastcgi_read_timeout            900;
    fastcgi_index                   index.php;
    fastcgi_pass                    127.0.0.1:9000;
    fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param                   CLASS_ENVIRONMENT LYLE;
    include                         /etc/nginx/fastcgi_params;
}

gzip            on;
gzip_min_length 1000;
gzip_proxied    any;
gzip_types      text/plain application/xml text/css text/js application/x-javascript;

sendfile        off;

}

3 个答案:

答案 0 :(得分:13)

您只需要放置可以解析此类域名的解析器:

resolver                  8.8.8.8 valid=300s;
resolver_timeout          10s;

Google DNS(8.8.8.8)可以解析它,但它解析为属于网络类C的内部地址。

$ dig @8.8.8.8 www.class.com.192.168.33.10.xip.io
;; ANSWER SECTION:
www.class.com.192.168.33.10.xip.io. 299 IN A    192.168.33.10

答案 1 :(得分:10)

你的问题来自这条线:

proxy_pass http://www.class.com.192.168.33.10.xip.io:8055;

服务器很可能难以解析该DNS名称。您可能还想查看https://serverfault.com/questions/341810/nginx-failing-to-resolve-upstream-names-on-reload-even-if-they-do-resolve-by-the

答案 2 :(得分:1)

可能有点晚了,但有一个简单的解决方案。变化

www.class.com.192.168.33.10.xip.io

www.class.com.192.168.33.10.nip.io

它应该在任何DNS上解决。