# comfyui-mcp RunPod reverse proxy — SELF-CONTAINED (no include/snippet deps). # ============================================================================= # Replaces the base image's /etc/nginx/nginx.conf. The base's /start.sh runs # `service nginx start` reading THIS file at boot. # # Public HTTP :3000 -> ComfyUI :3001 (the comfyui-mcp panel / connect target) # * websocket-aware (/ws, /queue/join, and the live-preview upgrade on /) # * "starting" fallback: while ComfyUI (:3001) is down, 502s are rewritten to a # friendly readme.html (HTTP 200) instead of nginx's raw error page. # # Also fronts the two extra services on RunPod-convention ports: # :8081 -> code-server :8080 # :8001 -> app-manager :8000 # (JupyterLab :8888 and SSH :22 are served directly by the base — not proxied.) # ============================================================================= worker_processes auto; events { worker_connections 2048; } http { client_max_body_size 1024M; # large model / image uploads sendfile on; # WebSocket upgrade plumbing (Connection: upgrade only when requested). map $http_upgrade $connection_upgrade { default upgrade; '' close; } # ---- shared proxy behavior, applied per-server via the directives below ---- # (Defined at server scope so all locations inherit them; ComfyUI generations # and websockets need long timeouts.) # ============================ ComfyUI (:3000 -> :3001) ==================== server { listen 3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; 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_cache_bypass $http_upgrade; proxy_buffering off; # stream SSE/preview promptly proxy_read_timeout 3600s; # long generations / idle websockets proxy_send_timeout 3600s; # Show the "starting" page instead of a raw 502 until ComfyUI is up. proxy_intercept_errors on; error_page 502 504 =200 @starting; location /ws { proxy_pass http://127.0.0.1:3001; } location /queue/join { proxy_pass http://127.0.0.1:3001; } location / { proxy_pass http://127.0.0.1:3001; } location @starting { proxy_intercept_errors off; add_header Cache-Control no-cache; root /usr/share/nginx/html; rewrite ^(.*)$ /readme.html break; } } # ============================ code-server (:8081 -> :8080) ================= server { listen 8081; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 3600s; proxy_intercept_errors on; error_page 502 504 =200 @starting8081; location / { proxy_pass http://127.0.0.1:8080; } location @starting8081 { proxy_intercept_errors off; root /usr/share/nginx/html; rewrite ^(.*)$ /readme.html break; } } # ============================ app-manager (:8001 -> :8000) ================= server { listen 8001; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 3600s; proxy_intercept_errors on; error_page 502 504 =200 @starting8001; location / { proxy_pass http://127.0.0.1:8000; } location @starting8001 { proxy_intercept_errors off; root /usr/share/nginx/html; rewrite ^(.*)$ /readme.html break; } } # ============================ File Browser (:8083 -> :8082) ================ # Web file manager rooted at /workspace (browse/upload/download/delete). # client_max_body_size 0 = no cap, so multi-GB model uploads aren't rejected. server { listen 8083; client_max_body_size 0; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 3600s; proxy_request_buffering off; # stream large uploads straight through proxy_intercept_errors on; error_page 502 504 =200 @starting8083; location / { proxy_pass http://127.0.0.1:8082; } location @starting8083 { proxy_intercept_errors off; root /usr/share/nginx/html; rewrite ^(.*)$ /readme.html break; } } }