【发布时间】:2022-02-01 00:29:20
【问题描述】:
我想通过这种行为在 Nginx 中使用反向代理的“proxy_pass”:
- 当有人尝试访问“https://myweb.com”时,proxypass 会重定向到“https://myproxyweb.com”
- 当有人尝试访问“https://myweb.com/foo”时,proxypass 会重定向到“https://myproxyweb.com”
总之,我想将所有路径代理传递到我的代理网站的根目录。
我有这个,但不起作用:
location / {
proxy_pass https://myproxyweb.com/;
}
它不起作用,因为当我尝试转到“https://myweb.com/foo”时,Nginx 尝试显示“https://myproxyweb.com/foo”
【问题讨论】:
-
使用
location / { rewrite ^ / break; proxy_pass https://myproxyweb.com; }
标签: nginx nginx-reverse-proxy nginx-location