worker_processes auto;
pid /tmp/nginx.pid;

events {
    worker_connections 1024;
    use epoll;
    multi_accept on;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /tmp/access.log;
    error_log /tmp/error.log;

    sendfile on;
    keepalive_timeout 65;

    # Gzip compression
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_types
        text/plain
        text/css
        application/javascript
        application/json
        application/xml
        application/rss+xml
        image/svg+xml;

    server {
        listen 8080;
        server_name localhost;

        root /usr/share/nginx/html;
        index index.html;

        # Health check endpoint
        location = /health {
            return 200 "ok";
            add_header Content-Type text/plain;
        }

        # Cache immutable build assets from Astro
        location /_astro/ {
            expires 30d;
            add_header Cache-Control "public, max-age=2592000, immutable";
        }

        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}
