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. javascript - js 有什么優雅的辦法實現在同時打開的兩個標簽頁間相互通信?2. css3 - Typecho 后臺部分表單按鈕在 Chrome 下出現靈異動畫問題,求解決3. javascript - angular和jquery都用到了$符號,一起用會不會沖突?4. javascript - 怎樣限制同一個瀏覽器不能登錄兩個賬號5. 想找個php大神仿個網站。6. java - android代碼重構:如何把app設置里的頭像UI做成通用的?7. java - 新手做一個安卓視頻播放器,想實現一個進度條,按鈕那種在視頻下方懸浮的功能,不知道思路!8. javascript - jquery怎么給select option一個點擊時觸發的事件,如圖 如果選擇自定義觸發一個時間?9. nginx配置server模塊的問題10. mysql優化 - 關于mysql分區
