7

I am trying to run Jupyter Lab on a VPS with the following nginx config


# 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;
  }

}

Then I simply run "jupyter lab --no-browser" from linux shell on the VPS.

I get a lot of these errors in the console

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

I've tried modifying ~/.jupyter/jupyter_notebook_config.py file to set "allow_origin = '*' " but that hasn't worked for me. How should I fix the Cross Origin API request?

Kiwiheretic
  • 308
  • 2
  • 12

1 Answers1

0

when i use this config, resolved

c.Spawner.args = [f'--NotebookApp.allow_origin={"*"}']
c.JupyterHub.tornado_settings = {
    'headers': {
        'Access-Control-Allow-Origin': '*',
    },
}

https://github.com/jupyterhub/jupyterhub/issues/1087

Demh
  • 1
  • 2