# Trust NPM-Proxy für Real-IP + Forwarded-Proto set_real_ip_from 0.0.0.0/0; real_ip_header X-Forwarded-For; real_ip_recursive on; upstream php-fpm { server app:9000; } upstream reverb { server reverb:8080; } upstream vite { server host.docker.internal:5173; } # === app.dev.clupilot.com === server { listen 80; server_name app.dev.clupilot.com; root /var/www/html/public; index index.php; client_max_body_size 100M; # Vite HMR WebSocket — only location that needs Connection: upgrade location /vite-hmr { proxy_pass http://vite; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_read_timeout 86400; } # Production build assets — serve statically (never proxied to Vite) location ^~ /build/ { alias /var/www/html/public/build/; try_files $uri =404; expires 1y; add_header Cache-Control "public, immutable"; } # CSS files — force Accept: text/css so Vite returns actual CSS (not JS module wrapper) location ~ \.css(\?.*)?$ { proxy_pass http://vite; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_set_header Accept "text/css"; proxy_hide_header Cache-Control; proxy_hide_header Expires; add_header Cache-Control "no-store, no-cache, must-revalidate" always; } # Vite module resolution (@vite, @id, @fs, resources, node_modules) location ~ ^/(@vite|@id|@fs|resources|node_modules)/ { proxy_pass http://vite; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_hide_header Cache-Control; proxy_hide_header Expires; add_header Cache-Control "no-store, no-cache, must-revalidate" always; } location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_pass php-fpm; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS on; fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto; include fastcgi_params; } } # === api.dev.clupilot.com === server { listen 80; server_name api.dev.clupilot.com; root /var/www/html/public; index index.php; location / { try_files $uri /index.php?$query_string; } location ~ \.php$ { fastcgi_pass php-fpm; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS on; fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto; include fastcgi_params; } } # === ws.dev.clupilot.com → Reverb === server { listen 80; server_name ws.dev.clupilot.com; location / { proxy_pass http://reverb; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto https; proxy_read_timeout 86400; } }