由于环境比较复杂,在nginx启动时,可能外部机房的网络没有连接外网
这时nginx启动就会报错如下:

2020/04/15 11:10:09 [emerg] 4027#0: host not found in upstream "XXXXX.XXXXXX.com" in .//conf/nginx.conf:76

解决方法有两种:

第一种

在/etc/hosts中添加域名对应的IP,或者直接在proxy_pass处配置IP

117.118.12.2       XXXXX.XXXXXX.com

另一种:

不直接在proxy_pass后写域名,而通过变量的方式配置,如下:

 set $target https://www.xxx.com;
 proxy_pass $target ;

除了上面的配置之外,还要在server属性的平行域下使用resolver指令,如下

resolver 114.114.114.114;

原文地址:https://www.cnblogs.com/think-in-java/p/10560631.html

posted on 2020-04-15 15:02  步孤天  阅读(2746)  评论(0编辑  收藏  举报