[case2]記一個nginx host not found異常

本文主要記錄一下nginx的host not found異常html

背景

某個內部域名,在A,B機器均可以,可是在C機器解析不了,nginx啓動報錯linux

nginx: [emerg] host not found in upstream "demo.com.cn" in /usr/local/openresty/nginx/conf/nginx.conf:95

resolver

怎麼辦了,這下nginx的resolver指定就派上用場了。在A,B機器上查看他們的dnsnginx

➜  ~ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.100.1

配置nginx dns

location /fix-dns {
            resolver 192.168.100.1 valid=300s;
            set $demohost demo.com.cn;
            proxy_pass http://$demohost/api/xxx ;
        }
固然也能夠根據狀況將resolver放在server模塊底下。

doc

相關文章
相關標籤/搜索