upstream api {
    server api:8000;
    keepalive 32;
}

server {
    listen 80;
    server_name _;

    # Increase body size for attachment uploads
    client_max_body_size 30M;

    location /health {
        proxy_pass http://api/health;
        access_log off;
    }

    location / {
        proxy_pass http://api;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # Webhook endpoints need longer timeouts
        proxy_read_timeout 60s;
        proxy_connect_timeout 10s;

        # HTTP/1.1 for keepalive
        proxy_http_version 1.1;
        proxy_set_header Connection "";
    }
}
