Anonymous 发表于 2021-5-6 10:11:52

nginx 启动错误"nginx: [emerg] host not found in upstream "解决方案

nginx 启动错误"nginx: host not found in upstream "解决方案
问题描述:
[*]

server {


[*]

listen 80;


[*]

server_name yq.object.home.com;


[*]

charset utf-8;


[*]

access_log /www/logs/yq.object.home.log;


[*]

location / {


[*]

proxy_set_header Host yq.object.com;


[*]

proxy_set_header DFROM 'yq.object.home.com';


[*]

proxy_pass http://yq.object.com:8080/object/home.php;


[*]

}


[*]

}


利用nginx进行反向代理的时候,我们会配置proxy_pass。在启动nginx的时候,会报nginx: host not found in upstream "yq.object.com" in /usr/local/nginx/conf/vhost/yq.nginx.com.conf:19 这个错误。其实nginx配置语法上没有错误的,只是系统无法解析这个域名,所以报错. 解决办法就是添加dns到/etc/resolv.conf 或者是/etc/hosts,让其能够解析到IP。具体步骤如下:vim /etc/hosts修改hosts文件,在hosts文件里面加上一句127.0.0.1       localhost.localdomain   yq.object.com
其实 这和windows下的hosts文件的修改是一样的。具体可以去了解一下hosts的作用

页: [1]
查看完整版本: nginx 启动错误"nginx: [emerg] host not found in upstream "解决方案