我正在尝试使用以下 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;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我只需从 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
Run Code Online (Sandbox Code Playgroud)
我尝试修改 ~/.jupyter/jupyter_notebook_config.py 文件来设置“allow_origin = '*'”,但这对我不起作用。我应该如何修复跨域 API 请求?
小智 0
当我使用这个配置时,解决了
c.Spawner.args = [f'--NotebookApp.allow_origin={"*"}']
c.JupyterHub.tornado_settings = {
'headers': {
'Access-Control-Allow-Origin': '*',
},
}
Run Code Online (Sandbox Code Playgroud)
https://github.com/jupyterhub/jupyterhub/issues/1087
| 归档时间: |
|
| 查看次数: |
2151 次 |
| 最近记录: |