首頁  >  問答  >  主體

http - nginx 反向代理 url 錯誤

我在內網的機器A上用docker部署了一個jupyter notebook#,其ip10.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,本來希望urlchild.testgroup.org/notebook/treechild.testgroup.org/notebook/sign_in,但跳轉時,包括後續的ajax請求都不會自動加上/notebook/這一段,變成了child.testgroup.org/treechild.testgroup.org /sign_in

請大家幫忙看看怎麼辦,是修改nginx配置還是需要其它的要素。

世界只因有你世界只因有你2662 天前1167

全部回覆(1)我來回復

  • 巴扎黑

    巴扎黑2017-06-06 09:56:28

    proxy_pass後面加上/notebook/,並且希望child.testgroup.org/notebook可訪問,那location應該為/notebook

    location /notebook {
                    proxy_pass http://10.11.11.10:8888/notebook/;
                    proxy_redirect off;
                    ...
            }

    回覆
    0
  • 取消回覆