Last active
July 18, 2020 00:14
-
-
Save kent119/bc1f05a1dc3bab0a241ea21420e684a5 to your computer and use it in GitHub Desktop.
Config Nginx as a reverse proxy for Jupyter notebook on VPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-enabled/some.domain | |
# Change the server name {some.domain} | |
# Change the {host.of.notebook} and {port} in the following locations | |
server { | |
listen 80; | |
# Change the server name {some.domain} | |
server_name some.domain; | |
location / { | |
# Change the {host.of.notebook} and {port} | |
proxy_pass http://host.of.notebook:port; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_read_timeout 86400; | |
} | |
client_max_body_size 50M; | |
error_log /var/log/nginx/error.log; | |
location ~* /(api/kernels/[^/]+/(channels|iopub|shell|stdin)|terminals/websocket)/? { | |
# Change the {host.of.notebook} and {port} | |
proxy_pass http://host.of.notebook:port; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_http_version 1.1; | |
#proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Upgrade "websocket"; | |
proxy_set_header Connection "upgrade"; | |
proxy_read_timeout 86400; | |
} | |
} |
Does this work if
{host.of.notebook}
islocalhost
?
I'm editing ~/.jupyter/jupyter_notebook_config.py
adding c.NotebookApp.local_hostnames = ['localhost', 'XXXXXX'] where XXXX is a server name on nginx and it works with SSL
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this work if
{host.of.notebook}
islocalhost
?