server { listen 80; server_name _; root /var/www/html/public; index index.php index.html; charset utf-8; # Gzip compression gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; gzip_min_length 1000; # Handle static files directly location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|map)$ { expires max; log_not_found off; access_log off; } location /build/ { expires max; add_header Cache-Control "public, immutable"; gzip_static on; } # Laravel routing — try files, then directories, then pass to index.php location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { log_not_found off; access_log off; } # PHP-FPM — pass .php requests to laravel-app location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass laravel-app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_read_timeout 300; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; } # Deny access to hidden files location ~ /\.(?!well-known).* { deny all; } error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; }