This nginx
config file is fairly standard fare except for the two location
blocks within the main section for HUB.DOMAIN.tld. To create a new site for jupyterhub in your Nginx config, make a new file in sites.enabled
, e.g. /etc/nginx/sites.enabled/jupyterhub.conf
:
# 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;
}
# {domain} -> {port number}
server {
server_name {domain};
location / {
proxy_pass http://127.0.0.1:{port number};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
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;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/lab.divogy.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/lab.divogy.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
Please refer to page: https://jupyterhub.readthedocs.io/en/stable/howto/configuration/config-proxy.html