events {
    worker_connections 1024;
}

http {
    upstream zk_sequencer {
        server zk-sequencer:3001;
    }

    server {
        listen 80;
        server_name _;

        location /health {
            return 200 'OK';
            add_header Content-Type text/plain;
        }

        location /api/ {
            proxy_pass http://zk_sequencer/;
            proxy_http_version 1.1;
            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;

            # CORS headers
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'Content-Type';
        }

        location /metrics {
            proxy_pass http://zk-sequencer:9001/metrics;
        }
    }
}
