nginx

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > nginx > JUPYTER服务的NGINX反向代理配置

JUPYTER服务的NGINX反向代理配置过程

作者:enjoy编程

文章介绍了如何配置Jupyter Notebook和Nginx以支持WebSocket协议,首先,检查并生成Jupyter配置文件,设置密码,然后,在Nginx配置文件中为Jupyter配置代理,确保支持WebSocket

jupyter 配置

配置文件在 /{user.dir}/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:2b64ebc42383:6f0cd4eb5ea9ede24b76e3baebe91aa1d051f62c'
c.NotebookApp.port = 8888
c.NotebookApp.iopub_data_rate_limit=1.0e10
#配置 jupyter 的路径
c.NotebookApp.base_url = '/nb/'

nginx 配置

jupyter 使用了 websocket 协议,所以需要配置支持 websocket。

在nginx的配置文件conf/nginx.conf文件中的http.server中配置代理如下:

	location /nb {
           proxy_pass http://172.25.101.28:10088/nb;
           proxy_set_header Host $host:$server_port;
           proxy_set_header X-Real-Scheme $scheme;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

		   # WebSocket support
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";

           proxy_read_timeout 120s;
           proxy_next_upstream error;
           proxy_redirect off;
           proxy_buffering off;
        }

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文