server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx/html/public;
    client_max_body_size ${NGINX_MAX_BODY_SIZE};

    access_log /dev/stdout;
    error_log /dev/stderr error;

    index index.html index.htm index.php;

    # Handle static files directly
    location ~* \.(css|js|ico|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
        try_files $uri =404;
    }

    # Handle API routes and other backend paths
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # PHP-FPM processing
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass api: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;
    }

    # Deny access to . files
    location ~ /\. {
        deny all;
    }
} 