# Map for WebSocket connections map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; # Root location redirects to webapp location / { proxy_pass http://webapp:3000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; 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_cache_bypass $http_upgrade; } # Facilitator API endpoint location /facilitator/api/ { proxy_pass http://facilitator:3000/api/; proxy_http_version 1.1; 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_cache_bypass $http_upgrade; } # VNC WebSocket proxy with improved WebSocket handling location /vnc-proxy/ { proxy_pass http://webapp:3000/vnc-proxy/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_read_timeout 86400; proxy_send_timeout 86400; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_buffering off; } # Direct WebSocket connection to VNC server location /websockify { proxy_pass http://remote-desktop:6901/websockify; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_read_timeout 86400; proxy_send_timeout 86400; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_buffering off; } # Health check endpoint location /health { access_log off; return 200 "healthy\n"; } # Error handling error_page 500 502 503 504 /50x.html; location = /50x.html { proxy_pass http://webapp:3000/50x.html; } }