首页 > 解决方案 > nginx反向代理意外重定向

问题描述

我有 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)

标签: httpnginxnetworkingnginx-reverse-proxy

解决方案


这是 chrome 缓存来自 nginx 对http://10.0.0.1/blog/的旧响应。清除浏览器缓存并再次尝试给出了预期的结果。


推荐阅读