【发布时间】:2021-01-12 19:02:55
【问题描述】:
我有 nginx 作为反向代理运行,配置为 /etc/nginx/sites-enabled/10.0.0.1.conf
server {
listen 80;
server_name 10.0.0.1;
location /blog/ {
proxy_pass http://127.0.0.1:8080/;
}
}
以及在 127.0.0.1:8080 上运行的博客服务。
当我在机器上查询 http://localhost/blog/ 时,我从博客服务中得到了预期的响应。但是,当从http://10.0.0.1/blog/ 查询时,nginx 会重定向到http://10.0.0.1,仅此而已。
这个配置有什么问题?为什么http://10.0.0.1/blog/ 不反向代理到 http://localhost:8080 博客服务?
nginx 版本:nginx/1.18.0 (Ubuntu)
【问题讨论】:
-
您确定重定向是由于 Nginx 而不是 proxy_pass 目标而发生的吗?我不确定您的 proxy_path (URI) 中是否需要斜杠。 Check the doc
-
我关闭了博客应用程序,因此 8080 上没有任何内容,并且重定向仍然发生。
-
curl -I http://10.0.0.1/blog/返回什么?
标签: http nginx networking nginx-reverse-proxy