Skip to main content
 首页 » 编程设计

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

2024年09月07日25wuhuacong

我有一个无所事事的盒子,已经运行了一段时间,今天,由于某种原因,当我尝试重新启动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

-更新-
运行以下命令检查端口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; 

}

请您参考如下方法:

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

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