由于环境比较复杂,在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

相关文章:

  • 2022-12-23
  • 2021-04-07
  • 2021-05-18
  • 2021-12-21
  • 2021-05-01
猜你喜欢
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-08
  • 2022-12-23
相关资源
相似解决方案