nginx 无法通过 reverse_proxy 向 docker 隐藏端口

nginx cannot hide port from docker with reverse_proxy

提问人:LiechtensteinSpy 提问时间:11/16/2023 最后编辑:LiechtensteinSpy 更新时间:11/16/2023 访问量:17

问:

在我的 nginx.conf 中使用 proxy_pass 和上游,我在重定向时仍然无法隐藏端口。

我有两个 docker 容器,一个带有 nginx,第二个带有我需要连接的服务,但是当我使用或我仍然移动到带有端口的服务窗口时:127.0.0.1/service127.0.0.1/service/http://127.0.0.1:8888/login?next=%2Flab%3F

但是当我尝试或收到 404 错误时,但 URL 看起来像我正在寻找的那个:但只有 404 错误。localhost/servicelocalhost/service/http://localhost/login?next=%2Flab%2F%2F

Nginx.conf 中:

upstream jupyter {
        server jupyterlab:8888;
}

server {
        listen nginx:80;

        server_name 127.0.0.1 www.127.0.0.1 ;


        location /jupyter {
                proxy_pass http://jupyter/lab/;
        }
}

p.s. 我添加了 / to,但它没有改变任何东西location /jupyter/

地点 nginx-reverse-proxy proxypass nginx-upstreams

评论


答: 暂无答案