Setting up jupyter lab behind a reverse proxy (nginx): Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
How to reverse proxy jupyter:
How to reverse proxy jupyter:
    On your /etc/nginx/sites-available/default
 
where 9068 is the port you have configured... jupyter
nano /etc/nginx/sites-available/default


<pre>
<pre>

Revision as of 17:54, 27 January 2021

How to reverse proxy jupyter:

nano /etc/nginx/sites-available/default
server {
    ...
       location ^~ /__lab__/ {
            proxy_pass http://localhost:9068/;
            # include /etc/nginx/includes/lab.conf;

            # this line is only useful for the sandbox!
            rewrite /(.*) /sandbox/$1  break;

            error_page 502 /lab/502.html;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_http_version 1.1;
            proxy_redirect off;
            proxy_buffering off;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
        }

Generate a jupyter password "hash", in python (3) ...

python
from IPython.lib import passwd
print(passwd("yourspecialpassword"))

In a (new) jupyter config file:

 nano ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.base_url = '/__lab__/'
c.NotebookApp.port =9068
c.NotebookApp.trust_xheaders = True
c.NotebookApp.port_retries = 0
c.NotebookApp.password = 'password_hash_from_python_above'
c.NotebookApp.allow_remote_access = True