worker_processes 1; error_log /var/log/nginx/error.log warn; pid /run/nginx/nginx.pid; events { worker_connections 1024; } http { 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"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; # Temp paths (writable by non-root) client_body_temp_path /run/nginx/client_temp; proxy_temp_path /run/nginx/proxy_temp; fastcgi_temp_path /run/nginx/fastcgi_temp; uwsgi_temp_path /run/nginx/uwsgi_temp; scgi_temp_path /run/nginx/scgi_temp; # Gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript text/xml; gzip_min_length 256; gzip_vary on; # WebSocket upgrade map (must be before server block) map $http_upgrade $connection_upgrade { default upgrade; '' ''; } # Upstreams upstream airflow { server 127.0.0.1:8080; keepalive 4; } upstream refresh { server 127.0.0.1:5000; keepalive 2; } server { listen 7860; server_name _; client_max_body_size 100M; # Security headers add_header X-Frame-Options SAMEORIGIN always; add_header X-Content-Type-Options nosniff always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy strict-origin-when-cross-origin always; # ---- Refresh service ---- location /refresh { proxy_pass http://refresh; proxy_set_header Host $host; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_read_timeout 120s; } location /config { proxy_pass http://refresh; proxy_set_header Host $host; proxy_set_header Connection ""; proxy_http_version 1.1; } location /health { proxy_pass http://refresh; proxy_set_header Host $host; proxy_set_header Connection ""; proxy_http_version 1.1; } location /status { proxy_pass http://refresh; proxy_set_header Host $host; proxy_set_header Connection ""; proxy_http_version 1.1; } # ---- Airflow webserver ---- location / { proxy_pass http://airflow; 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; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_read_timeout 300s; proxy_connect_timeout 75s; # WebSocket support (for live log tailing) proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } }