Added: Changed Nginx
This commit is contained in:
		@@ -66,7 +66,7 @@ base_url = os.environ.get("JUPYTERHUB_BASE_URL", "/jupyter/")
 | 
			
		||||
c.JupyterHub.bind_url = f"http://0.0.0.0:{port}{base_url}"
 | 
			
		||||
 | 
			
		||||
# Database configuration
 | 
			
		||||
c.JupyterHub.db_url = f"postgresql://{os.environ['POSTGRES_USER']}:{os.environ['POSTGRES_PASSWORD']}@stack-{os.environ['POSTGRES_HOST']}:5432/{os.environ['POSTGRES_DB']}"
 | 
			
		||||
c.JupyterHub.db_url = f"postgresql://{os.environ['POSTGRES_USER']}:{os.environ['POSTGRES_PASSWORD']}@{os.environ['POSTGRES_HOST']}:5432/{os.environ['POSTGRES_DB']}"
 | 
			
		||||
# c.JupyterHub.db_url = 'sqlite:///jupyterhub.sqlite'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -100,9 +100,7 @@ c.JupyterHub.template_paths = ["/etc/jupyterhub/templates"]
 | 
			
		||||
c.JupyterHub.spawner_class = DockerSpawner
 | 
			
		||||
 | 
			
		||||
# Spawn Containers from this Image
 | 
			
		||||
c.DockerSpawner.image = os.environ.get(
 | 
			
		||||
    "NOTEBOOK_IMAGE", "jupyter/scipy-notebook:latest"
 | 
			
		||||
)
 | 
			
		||||
c.DockerSpawner.image = os.environ.get("NOTEBOOK_IMAGE", "jupyter/base-notebook:latest")
 | 
			
		||||
 | 
			
		||||
# Connect Containers to this network
 | 
			
		||||
network_name = os.environ.get("DOCKER_NETWORK_NAME", "stack_default")
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,5 @@ services:
 | 
			
		||||
    volumes:
 | 
			
		||||
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
 | 
			
		||||
      - ./conf.d:/etc/nginx/conf.d:ro
 | 
			
		||||
      - ./snippets:/etc/nginx/snippets:ro
 | 
			
		||||
      - ./ssl:/etc/nginx/ssl:ro
 | 
			
		||||
      - ../logs/nginx:/etc/log/nginx
 | 
			
		||||
      - ./discord.html:/var/www/static/index.html:ro
 | 
			
		||||
      - ../logs/nginx:/var/log/nginx
 | 
			
		||||
 
 | 
			
		||||
@@ -1,43 +1,44 @@
 | 
			
		||||
# Shared proxy headers
 | 
			
		||||
include /etc/nginx/snippets/proxy-headers.conf;
 | 
			
		||||
 | 
			
		||||
# nginx/conf.d/jupyterhub.conf
 | 
			
		||||
server {
 | 
			
		||||
    listen 80 default_server;
 | 
			
		||||
    server_name _;
 | 
			
		||||
 | 
			
		||||
    listen 80;
 | 
			
		||||
    server_name _;  # Respond to all hostnames
 | 
			
		||||
    
 | 
			
		||||
    # JupyterHub with base URL /jupyter/
 | 
			
		||||
    location /jupyter/ {
 | 
			
		||||
        proxy_pass http://jupyterhub:8000/;  # Docker service name
 | 
			
		||||
        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;
 | 
			
		||||
        
 | 
			
		||||
        # Apply shared proxy headers
 | 
			
		||||
        include /etc/nginx/snippets/proxy-headers.conf;
 | 
			
		||||
        
 | 
			
		||||
        # Special WebSocket timeout
 | 
			
		||||
        # WebSocket support (crucial for Jupyter)
 | 
			
		||||
        proxy_http_version 1.1;
 | 
			
		||||
        proxy_set_header Upgrade $http_upgrade;
 | 
			
		||||
        proxy_set_header Connection "upgrade";
 | 
			
		||||
        proxy_read_timeout 86400;
 | 
			
		||||
        
 | 
			
		||||
        # Handle large file uploads
 | 
			
		||||
        client_max_body_size 100M;
 | 
			
		||||
        proxy_request_buffering off;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # Redirect /jupyter to /jupyter/
 | 
			
		||||
    location = /jupyter {
 | 
			
		||||
    # Redirect root to JupyterHub
 | 
			
		||||
    location = / {
 | 
			
		||||
        return 302 /jupyter/;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    # Stativ site conf
 | 
			
		||||
    root /var/www/static;
 | 
			
		||||
    index index.html;
 | 
			
		||||
 | 
			
		||||
    location / {
 | 
			
		||||
        try_files $uri $uri/ =404;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # Cache static assets
 | 
			
		||||
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
 | 
			
		||||
        expires 30d;
 | 
			
		||||
        add_header Cache-Control "public, no-transform";
 | 
			
		||||
    # 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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,30 +1,38 @@
 | 
			
		||||
user  nginx;
 | 
			
		||||
worker_processes  auto;
 | 
			
		||||
 | 
			
		||||
error_log  /var/log/nginx/error.log warn;
 | 
			
		||||
pid        /var/run/nginx.pid;
 | 
			
		||||
user nginx;
 | 
			
		||||
worker_processes auto;
 | 
			
		||||
error_log /var/log/nginx/error.log warn;
 | 
			
		||||
pid /var/run/nginx.pid;
 | 
			
		||||
 | 
			
		||||
events {
 | 
			
		||||
    worker_connections  1024;
 | 
			
		||||
    worker_connections 1024;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
http {
 | 
			
		||||
    include       /etc/nginx/mime.types;
 | 
			
		||||
    default_type  application/octet-stream;
 | 
			
		||||
    include /etc/nginx/mime.types;
 | 
			
		||||
    default_type application/octet-stream;
 | 
			
		||||
 | 
			
		||||
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 | 
			
		||||
                      '$status $body_bytes_sent "$http_referer" '
 | 
			
		||||
                      '"$http_user_agent" "$http_x_forwarded_for"';
 | 
			
		||||
    # Log format
 | 
			
		||||
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
 | 
			
		||||
                    '$status $body_bytes_sent "$http_referer" '
 | 
			
		||||
                    '"$http_user_agent" "$http_x_forwarded_for"';
 | 
			
		||||
 | 
			
		||||
    access_log  /var/log/nginx/access.log  main;
 | 
			
		||||
    access_log /var/log/nginx/access.log main;
 | 
			
		||||
 | 
			
		||||
    sendfile        on;
 | 
			
		||||
    keepalive_timeout  65;
 | 
			
		||||
    # Basic settings
 | 
			
		||||
    sendfile on;
 | 
			
		||||
    tcp_nopush on;
 | 
			
		||||
    tcp_nodelay on;
 | 
			
		||||
    keepalive_timeout 65;
 | 
			
		||||
    types_hash_max_size 2048;
 | 
			
		||||
 | 
			
		||||
    # Gzip compression
 | 
			
		||||
    gzip  on;
 | 
			
		||||
    gzip_types text/plain text/css application/json application/javascript text/xml;
 | 
			
		||||
    gzip on;
 | 
			
		||||
    gzip_vary on;
 | 
			
		||||
    gzip_min_length 1024;
 | 
			
		||||
    gzip_types text/plain text/css text/xml text/javascript 
 | 
			
		||||
               application/json application/javascript application/xml+rss 
 | 
			
		||||
               application/atom+xml image/svg+xml;
 | 
			
		||||
 | 
			
		||||
    # Include modular configs
 | 
			
		||||
    # Include server configurations
 | 
			
		||||
    include /etc/nginx/conf.d/*.conf;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +0,0 @@
 | 
			
		||||
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
 | 
			
		||||
proxy_http_version 1.1;
 | 
			
		||||
proxy_set_header Upgrade $http_upgrade;
 | 
			
		||||
proxy_set_header Connection "upgrade";
 | 
			
		||||
		Reference in New Issue
	
	Block a user