server {
    listen 80;
    server_name _;

    # Wild Central Management Interface
    root /var/www/html/wild-central;
    index index.html;

    # API proxy to wild-central service
    location /api/ {
        proxy_pass http://localhost:5055;
        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;
    }

    # SSE events proxy (long-lived connections)
    location /api/v1/events {
        proxy_pass http://localhost:5055;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_buffering off;
        proxy_cache off;
        proxy_read_timeout 86400s;
    }

    # Static files - SPA routing support
    location / {
        try_files $uri $uri/ /index.html;
    }
}
