微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何从 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 举报,一经查实,本站将立刻删除。