Place both docker-compose.yml
and nginx.conf
in same working directory with an
appropriate SERVER.crt
and SERVER.key
for the server. Make sure docker
and
docker-compose
are installed, and run:
docker-compose up -d
jupyter: | |
image: jupyter/datascience-notebook | |
environment: | |
- PASSWORD=${PASSWORD} | |
nginx: | |
image: nginx | |
links: | |
- jupyter | |
volumes: | |
- ./nginx.conf:/etc/nginx/nginx.conf | |
- ./SERVER.crt:/etc/ssl/certs/SERVER.crt | |
- ./SERVER.key:/etc/ssl/private/SERVER.key | |
ports: | |
- 443:443 | |
restart: always |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
access_log /var/log/nginx/access.log; | |
sendfile on; | |
keepalive_timeout 0; | |
gzip on; | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
upstream jupyter { | |
server jupyter:8888 fail_timeout=0; | |
} | |
server { | |
listen 8888; | |
ssl on; | |
ssl_certificate /etc/ssl/certs/SERVER.crt; | |
ssl_certificate_key /etc/ssl/private/SERVER.key; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; | |
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; | |
proxy_set_header Host $http_host; # required for Docker client sake | |
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP | |
client_max_body_size 0; # disable any limits to avoid HTTP 413 for large uploads | |
location /jupyter { | |
rewrite ^/jupyter/(.*)$ /$1 break; | |
proxy_pass http://jupyter; | |
proxy_redirect http://jupyter/ $scheme://$host/jupyter/; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_read_timeout 20d; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
error_page 500 502 503 504 /500.html; | |
keepalive_timeout 0; | |
} | |
} |
what about just serving staring from / instead of ~?
where are the static files actually served from?
Thanks. It helped
Thank you, it works like a charm.
Thanks, It works for me
Thanks, works with nginx mainline and JH 0.8.1
Thanks for this - that worked for me, as well.
Hi, does anyone has been trying transfer the NGINX user uid header to jupyternotebook session? I mean something like to identify the authenticated user on the notebook session.
Thanks,
Dude you saved our ass here just now. Thanks :)
Thank you!. You've saved my time :)))))))))
Thank you!
Still works as of 2023, however note that on Safari, the kernel will seem like it's restarting continuously, while still generating the right cell output(s). If Firefox or Chrome is installed, better use that.
I've got many errors of the form below with the container, as well as with the official container. I turn of SSL:
WebSocket connection to 'ws://localhost/api/events/subscribe?token=9fe2a91c775e50ddc0535cf0cd55c58b38919586caf08470' failed:
Does anybody have the same problem, and perhaps a solution?
@dmikushin have you found a solution?
@alesito85 , kind of. First of all, not all websocket errors are an indication of issue. For example, if connection to the Jupyter website has been established, but then lost due to the internet or network interruption, then these errors are presented naturally, as for any socket connection that becomes broken. If Docker container has been restarted, this is also a legitimate cause of websocket errors. So these errors may be attributed to Nginx configuration only given stable networking conditions. Be sure to refresh the page first, to clear out the old errors.
Instead of carrying out an own Nginx configuration, please first take a look at the official one, as it might have changed in the newer versions of Jupyter.
Thanks this works!