昨天碰到一个坑,我想用本地的nginx代理paas平台上的api服务,api服务有内网访问域名,通过nginx配置如下:

location / {
proxy_pass http://api-test-yuntu-www-test.opaas.enncloud.cn;
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
index index.html index.htm;
}

通过错误日志一直看到nginx将内网域名解析成了内网ip,但是通过ip访问根本访问不到这个服务!

如是我将

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;

去掉了,它就不走ip了,直接域名转发(猜测paas平台内部做了域名转发)

posted on 2017-12-15 11:27  断肠夕阳丿  阅读(3909)  评论(0编辑  收藏  举报