diff --git a/basic-example/docker-compose.yml b/basic-example/docker-compose.yml index 1ad854e..a4d2d2c 100644 --- a/basic-example/docker-compose.yml +++ b/basic-example/docker-compose.yml @@ -1,7 +1,3 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -# JupyterHub docker-compose configuration file version: "3" services: @@ -36,6 +32,29 @@ services: # Notebook directory inside user image DOCKER_NOTEBOOK_DIR: /home/jovyan/work + proxy: + image: jupyterhub/configurable-http-proxy:4.6.0 + container_name: jupyterhub-proxy + restart: always + networks: + - jupyterhub-network + ports: + - "8002:8000" + command: ["--default-target=http://hub:8000"] + + reverse-proxy: + image: nginx:1.25.3 + container_name: jupyterhub-reverse-proxy + restart: always + networks: + - jupyterhub-network + ports: + - "8001:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - proxy + volumes: jupyterhub-data: diff --git a/basic-example/jupyterhub_config.py b/basic-example/jupyterhub_config.py index 028f65c..52b6c11 100644 --- a/basic-example/jupyterhub_config.py +++ b/basic-example/jupyterhub_config.py @@ -52,6 +52,7 @@ # Allow anyone to sign-up without approval c.NativeAuthenticator.open_signup = True + # Allowed admins admin = os.environ.get("JUPYTERHUB_ADMIN") if admin: diff --git a/basic-example/nginx.conf b/basic-example/nginx.conf new file mode 100644 index 0000000..5532fd7 --- /dev/null +++ b/basic-example/nginx.conf @@ -0,0 +1,26 @@ +events { + worker_connections 1024; +} + +http { + server { + listen 80; + + location / { + proxy_pass http://proxy:8000; # Assuming 'proxy' is the service name in docker-compose + + # WebSocket support + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + + # Handling real IP and scheme in proxied server + 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; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; + } + } +} \ No newline at end of file