server { listen 80; server_name _; root /var/www/html/public; index index.php; client_max_body_size 2m; # Built client assets (long-term cacheable) location /build/ { try_files $uri =404; expires 1y; add_header Cache-Control "public, immutable"; } # Laravel front controller / SPA entry (serves resources/views/app.blade.php) location / { try_files $uri $uri/ /index.php?$query_string; } # Only ever route index.php to PHP-FPM location ~ ^/index\.php(/|$) { include fastcgi_params; fastcgi_pass fpm:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root/index.php; } location ~ \.php$ { return 404; } # Optional HTTP input fallback (POST /api/game/{room}/input) location /api { include fastcgi_params; fastcgi_pass fpm:9000; fastcgi_param SCRIPT_FILENAME $document_root/index.php; } # Same-origin Reverb (Pusher-protocol) websocket + handshake location /app/ { proxy_pass http://reverb:8080; 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-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 60s; proxy_send_timeout 60s; } }