server { listen 80; server_name _; # Respond to all hostnames # JupyterHub with base URL /jupyter/ location /jupyter/ { proxy_pass http://jupyterhub:8000/jupyter/; 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_set_header X-Forwarded-Proto $scheme; # WebSocket support (crucial for Jupyter) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 86400; proxy_send_timeout 86400; # Disable buffering for WebSocket proxy_buffering off; # Handle large file uploads client_max_body_size 100M; proxy_request_buffering off; } # Redirect root to JupyterHub location = / { return 302 /jupyter/; } # Health check endpoint location /jupyter/hub/health { proxy_pass http://jupyterhub:8000/jupyter/hub/health; proxy_set_header Host $host; access_log off; allow all; } # Deny access to hidden files location ~ /\. { deny all; access_log off; log_not_found off; } }