【发布时间】:2021-03-18 19:24:19
【问题描述】:
在检查文档和 stackoverflow 数小时后,我仍然无法弄清楚如何做到这一点。
这是我的 nginx.conf:
http {
upstream backend {
least_conn;
server 192.168.77.81:8078 weight=4;
server 192.168.77.231:8078 weight=7 max_fails=1 fail_timeout=1s;
}
upstream static_backend {
server 192.168.77.81:8079;
}
server {
listen 8068;
access_log off;
error_log off;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static/ {
proxy_pass http://192.168.77.81:8079;
}
}
}
events {}
我想将所有http://192.168.77.81:8068/static 重定向到http://192.168.77.81:8079/static
但这一切都会导致 301 Moved Permanently 或 http://192.168.77.81:8078/static
这让我发疯了
我也尝试过别名和root,但它们都不起作用
任何建议将不胜感激!
【问题讨论】:
标签: nginx redirect routes reverse-proxy