# Nginx site configuration for Laravel on Ubuntu 24.04 # This config is for native Nginx (not Docker) behind Nginx Proxy Manager # Place this in /etc/nginx/sites-available/ and symlink to sites-enabled server { listen 80; listen [::]:80; # Replace with your domain or internal IP # Nginx Proxy Manager will forward traffic here server_name your-domain.com; root /var/www/your-app/public; index index.php index.html index.htm; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; charset utf-8; # Laravel routing location / { try_files $uri $uri/ /index.php?$query_string; } # Favicon and robots location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } # Error pages error_page 404 /index.php; # PHP-FPM configuration location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_hide_header X-Powered-By; # Timeouts fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; } # Deny access to hidden files location ~ /\.(?!well-known).* { deny all; } # Static file caching location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|txt|woff|woff2|ttf|svg)$ { expires 30d; add_header Cache-Control "public, immutable"; access_log off; } # Gzip compression gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml application/xml+rss application/x-font-ttf font/opentype image/svg+xml; client_max_body_size 100M; # Logging access_log /var/log/nginx/your-app-access.log; error_log /var/log/nginx/your-app-error.log; }