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}"
|
c.JupyterHub.bind_url = f"http://0.0.0.0:{port}{base_url}"
|
||||||
|
|
||||||
# Database configuration
|
# 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'
|
# c.JupyterHub.db_url = 'sqlite:///jupyterhub.sqlite'
|
||||||
|
|
||||||
|
|
||||||
@@ -100,9 +100,7 @@ c.JupyterHub.template_paths = ["/etc/jupyterhub/templates"]
|
|||||||
c.JupyterHub.spawner_class = DockerSpawner
|
c.JupyterHub.spawner_class = DockerSpawner
|
||||||
|
|
||||||
# Spawn Containers from this Image
|
# Spawn Containers from this Image
|
||||||
c.DockerSpawner.image = os.environ.get(
|
c.DockerSpawner.image = os.environ.get("NOTEBOOK_IMAGE", "jupyter/base-notebook:latest")
|
||||||
"NOTEBOOK_IMAGE", "jupyter/scipy-notebook:latest"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Connect Containers to this network
|
# Connect Containers to this network
|
||||||
network_name = os.environ.get("DOCKER_NETWORK_NAME", "stack_default")
|
network_name = os.environ.get("DOCKER_NETWORK_NAME", "stack_default")
|
||||||
|
@@ -9,7 +9,5 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
- ./conf.d:/etc/nginx/conf.d:ro
|
- ./conf.d:/etc/nginx/conf.d:ro
|
||||||
- ./snippets:/etc/nginx/snippets:ro
|
|
||||||
- ./ssl:/etc/nginx/ssl:ro
|
- ./ssl:/etc/nginx/ssl:ro
|
||||||
- ../logs/nginx:/etc/log/nginx
|
- ../logs/nginx:/var/log/nginx
|
||||||
- ./discord.html:/var/www/static/index.html:ro
|
|
||||||
|
@@ -1,43 +1,44 @@
|
|||||||
# Shared proxy headers
|
# nginx/conf.d/jupyterhub.conf
|
||||||
include /etc/nginx/snippets/proxy-headers.conf;
|
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80 default_server;
|
listen 80;
|
||||||
server_name _;
|
server_name _; # Respond to all hostnames
|
||||||
|
|
||||||
|
# JupyterHub with base URL /jupyter/
|
||||||
location /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
|
# WebSocket support (crucial for Jupyter)
|
||||||
include /etc/nginx/snippets/proxy-headers.conf;
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
# Special WebSocket timeout
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_read_timeout 86400;
|
proxy_read_timeout 86400;
|
||||||
|
|
||||||
|
# Handle large file uploads
|
||||||
|
client_max_body_size 100M;
|
||||||
|
proxy_request_buffering off;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redirect /jupyter to /jupyter/
|
# Redirect root to JupyterHub
|
||||||
location = /jupyter {
|
location = / {
|
||||||
return 302 /jupyter/;
|
return 302 /jupyter/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Health check endpoint
|
||||||
# Stativ site conf
|
location /jupyter/hub/health {
|
||||||
root /var/www/static;
|
proxy_pass http://jupyterhub:8000/jupyter/hub/health;
|
||||||
index index.html;
|
proxy_set_header Host $host;
|
||||||
|
access_log off;
|
||||||
location / {
|
allow all;
|
||||||
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";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Deny access to hidden files
|
# Deny access to hidden files
|
||||||
location ~ /\. {
|
location ~ /\. {
|
||||||
deny all;
|
deny all;
|
||||||
|
access_log off;
|
||||||
|
log_not_found off;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
user nginx;
|
user nginx;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log warn;
|
error_log /var/log/nginx/error.log warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
@@ -12,19 +11,28 @@ http {
|
|||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
# Log format
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
'$status $body_bytes_sent "$http_referer" '
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log main;
|
access_log /var/log/nginx/access.log main;
|
||||||
|
|
||||||
|
# Basic settings
|
||||||
sendfile on;
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
|
||||||
# Gzip compression
|
# Gzip compression
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_types text/plain text/css application/json application/javascript text/xml;
|
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;
|
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