背景:nginx 配置proxy_pass后,访问接口出现no resolver defined to resolve错误,或者接口直接502,404,需要配置 nginx resolver
server {
server_name wfk.mohuani.com
location / {
resolver 114.114.114.114;
proxy_pass https://wfk.mohuani.com/abc/$1/$2 ---404
proxy_pass https://www.baidu.com/abc/$1/$2 ---502
proxy_pass https://113.105.77.194/abc/$1/$2 ---404
proxy_pass https://127.0.0.1/abc/$1/$2 ---404
}
ps:个人猜测,当proxy_pass 设置为自身server_name 时,server_name会被转成127.0.0.1,导致接口报的是404,而不是502。
resolver 设置公共的DNS或者公司内部的DNS都可以
resolver 114.114.114.114;
resolver 8.8.8.8;