server {
    listen 443 ssl http2;
    server_name example.com api.example.com;
    root /var/www/lucky-spin/public;
    index index.php;
    server_tokens off;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Content-Security-Policy "base-uri 'self'; object-src 'none'; frame-ancestors 'self'" always;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~* ^/storage/.*\.(?:php[0-9]?|phtml|phar|phps|inc)$ {
        deny all;
    }

    location = /index.php {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }

    location ~ \.php$ {
        return 404;
    }

    location ~ /\.(?!well-known/) {
        deny all;
    }

    location ~* \.(?:env|log|sql|sqlite|bak|backup|old|swp)$ {
        deny all;
    }

    client_max_body_size 6m;
}
