【发布时间】:2019-08-26 13:25:34
【问题描述】:
我在开发环境中配置 nginx 反向代理时遇到了问题,当时我偶然发现了一种我不太了解的行为。
所以 nginx 正在监听 8080 端口。当我向我的开发服务器发出请求时,我可以访问我的开发服务器
localhost:8080
使用以下指令:
server {
listen 8080;
server_name site.com;
location / {
proxy_pass http://localhost:3000/;
proxy_redirect off;
}
但是当我将一个已知网站放入代理 pass_directive (如 google 或 apple)中时,行为会有所不同。我无法访问 e。 G。 apple.com 使用以下指令作为 localhost:8080 - 我立即被推送到真实网站而不是 localhost:
server {
listen 8080;
server_name site.com;
location / {
proxy_pass http://apple.com/;
proxy_redirect off;
}
这种行为是如何命名的,它是如何实现的?你们能否让我理解这一点的正确方向?谢谢。
【问题讨论】:
-
这就是我希望上述配置发生的事情。也许您的
proxy_redirect指令应该设置为on?
标签: nginx proxy reverse-proxy