我正尝试使用以下nginx配置在VPS上运行Jupyter Lab
# top-level http config for websocket headers
# If Upgrade is defined, Connection = upgrade
# If Upgrade is empty, Connection = close
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_name jupyter.kiwiheretic.xyz;
location / {
proxy_pass http://localhost:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host localhost;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# websocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
access_log /var/log/nginx/wiki.kiwiheretic.xyz.access.log combined;
error_log /var/log/nginx/wiki.kiwiheretic.xyz.eror.log;
location = /50x.html {
root /usr/share/nginx/www;
}
}
然后,我只需在VPS上的linux shell中运行“jupyter lab --no-browser”。
我在控制台中遇到很多这样的错误
W 2021-09-08 07:44:04.737 LabApp] Blocking Cross Origin API request for /lab/api/workspaces/default. Origin: http://jupyter.kiwiheretic.xyz, Host: localhost
我试过修改~/.jupyter/jupyter_notebook_config.py文件来设置“allow_origin = '*'“,但没有效果。我应该如何修复跨源API请求?
1条答案
按热度按时间s4n0splo1#
当我使用此配置时,已解决
https://github.com/jupyterhub/jupyterhub/issues/1087