您的位置:首页 > 运维架构 > Nginx

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

2014-04-11 14:27 2121 查看
问题描述:
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: [emerg] 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的作用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐