server { listen 8000; server_name _; root /var/www/html/public; index index.php; # Gestione SPA/Laravel: tutto passa per index.php location / { try_files $uri $uri/ /index.php?$query_string; } # Passa le richieste PHP a php-fpm locale location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; # Timeout generosi per operazioni Laravel pesanti (es. import, export) fastcgi_read_timeout 300; fastcgi_connect_timeout 300; } # Blocca accesso a file sensibili location ~ /\. { deny all; } location ~ /\.env { deny all; } # Cache statica per asset compilati location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ { expires 1y; add_header Cache-Control "public, immutable"; try_files $uri =404; } # Log access_log /dev/stdout; error_log /dev/stderr warn; }