使用Nginx反向代理JupyterHub, 实现Websocket转发和持久化链接

今天配置内网的JupyterHub,并用堡垒机做Nginx转发实现外网访问。中间遇到一些问题,最大的一个坑就是Jupyter是使用wss来传递信息的,因此在配置反代的时候要开启持久化配置,否则会一直报错。

我的配置参考如下:

#PROXY-START/

location /

{

    #expires 0;#注释掉了因为后面加了no-store参数

proxy_pass https://172.27.1.105;

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_set_header REMOTE-HOST $remote_addr;



#持久化连接相关配置实现wss转发

proxy_connect_timeout 30s;

proxy_read_timeout 86400s;

proxy_send_timeout 30s;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_redirect off;



#add_header X-Cache $upstream_cache_status;#使用自定的cache策略

add_header Cache-Control no-store;    

}

#PROXY-END/

 


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/283.html
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy