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

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search
 
Line 9: Line 9:
 
             proxy_pass http://localhost:9068/;
 
             proxy_pass http://localhost:9068/;
 
             # include /etc/nginx/includes/lab.conf;
 
             # include /etc/nginx/includes/lab.conf;
 
            # this line is only useful for the sandbox!
 
            rewrite /(.*) /sandbox/$1  break;
 
 
 
             error_page 502 /lab/502.html;
 
             error_page 502 /lab/502.html;
 
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Latest revision as of 17:55, 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;
            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