如何从 nginx 反向代理使用 jupter 服务器

问题描述

我需要管理多个 jupyter notebook 服务器,所以我想通过 Nginx 反向代理使用它们。

docker-compose.yaml

version: '3'

services:
  jupyter:
    image: jupyter/datascience-notebook
    container_name: 'jupyter-rp'
    ports:
      - 8888:8888

  reverse-proxy:
    image: Nginx
    volumes:
      - ./reverse-proxy/Nginx.conf:/etc/Nginx/Nginx.conf
    ports:
      - 80:80

反向代理/Nginx.conf

events {
    worker_connections  16;
}
http {
    server {
        listen 80;
        server_name localhost;

        location / {
            proxy_pass http://[Remote Server's local ip address]:8888/;
        }
    }
}

此设置运行良好,我可以通过 http://[Remote Server's local ip address]/

从我的开发环境访问 jupyter notebook 服务器

那我换个pass。

location /jupyter {
            proxy_pass http://[Remote Server's local ip address]:8888/;
        }

无法通过http://[Remote Server's local ip address]/jupyter/到达服务器 访问日志显示如下。

jupyter-rp       | [I 08:26:28.918 NotebookApp] 302 GET / (172.23.0.1) 0.940000ms
reverse-proxy_1  | 10.13.170.137 - - [06/May/2021:08:26:28 +0000] "GET /jupyter HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/90.0.4430.93 Safari/537.36"
reverse-proxy_1  | 10.13.170.137 - - [06/May/2021:08:26:28 +0000] "GET /tree? HTTP/1.1" 404 556 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/90.0.4430.93 Safari/537.36"
reverse-proxy_1  | 2021/05/06 08:26:28 [error] 23#23: *4 open() "/etc/Nginx/html/tree" Failed (2: No such file or directory),client: 10.13.170.137,server: localhost,request: "GET /tree? HTTP/1.1",host: "10.65.4.41"

此案例服务器尝试通过重定向返回 /etc/Nginx/html/tree。我应该如何更改 Nginx.conf?

这是类似的问题,但没有回答。 nginx proxy_pass serving from default path other than application's

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)