如何解决nginx proxy_pass总是在带有端口的上游返回404
我具有以下nginx要求。
我需要的是将localhost / test重定向到192.168.116.209:9009
如果我直接打192.168.116.209:9009/xxx
,它会按预期工作。
但是,当我访问localhost/test/xxx
时,它总是返回404。
我将日志放在后端,它显示日志,请求传入的uri是http://localhost/test/xxx
,它没有端口,实际上是nginx URL。有趣的是,此日志发生在后端,这意味着nginx将原始请求传递给后端,它只得到404。
什么是正确的配置? 这是我的Nginx配置
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream test {
server 192.168.116.209:9009;
}
server {
listen 80;
server_name localhost;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location /test {
proxy_pass http://192.168.116.209:9009;
}
}
}
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。