http - nginx 反向代理 url 错误
问题描述
我在内网的机器A上用docker部署了一个jupyter notebook,其ip为10.11.11.10,服务端口号为8888,机器B可以通过部门二级域名(如child.testgroup.org)访问其80端口的内容。
现在我在,B机的nginx上做反向代理,希望通过child.testgroup.org/notebook来访问jupyter notebook。我的配置如下:
location /notebook/ {proxy_pass http://10.11.11.10:8888/;proxy_redirect off;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_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection 'upgrade';}
但通过child.testgroup.org/notebook来访问时总是出现url错误,如下图:
jupyter notebook会跳转到/tree这个目录下,gitlab-ce会跳转到/sign_in,本来希望url是child.testgroup.org/notebook/tree及child.testgroup.org/notebook/sign_in,但跳转时,包括后续的ajax请求都不会自动加上/notebook/这一段,变成了child.testgroup.org/tree及child.testgroup.org/sign_in。
请大家帮忙看看怎么办,是修改nginx配置还是需要其它的要素。
问题解答
回答1:proxy_pass后面加上/notebook/,并且希望child.testgroup.org/notebook可访问,那location应该为/notebook
location /notebook {proxy_pass http://10.11.11.10:8888/notebook/;proxy_redirect off;...}
相关文章:
1. golang - 用IDE看docker源码时的小问题2. css - ul ol前边的标记如何调整样式呢3. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?4. dockerfile - 为什么docker容器启动不了?5. html - 爬虫时出现“DNS lookup failed”,打开网页却没问题,这是什么情况?6. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!7. dockerfile - [docker build image失败- npm install]8. css - chrome浏览器input记录上次cookie信息后,有个黄色背景~如何去除!9. mac连接阿里云docker集群,已经卡了2天了,求问?10. 用CSS3 box-sizing 属性实现两个并排的容器,如果想让容器中间有间隔该如何实现

网公网安备