server {
    listen 80;
    server_name localhost;

    root /var/www/public;
    index index.php index.html index.htm;

    # Access and error logs
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

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

    # Handle PHP scripts
    location ~ \.php$ {
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Disable access to .htaccess files
    location ~ /\.ht {
        deny all;
    }

    # Ensure proper caching for static assets
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        expires max;
        log_not_found off;
    }
}
