# Nginx configuration for API-only reverse proxy
# Control Plane accessed directly (not through nginx)

events {
    worker_connections 1024;
}

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

    # Logging
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Upstream - Hindsight API
    upstream hindsight_api {
        server hindsight:8888;
    }

    server {
        listen 80;
        server_name _;

        # API endpoints - forward with /hindsight prefix
        location /hindsight/ {
            proxy_pass http://hindsight_api;

            proxy_set_header Host $http_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;
        }

        # Redirect root to API docs
        location = / {
            return 301 /hindsight/docs;
        }
    }
}
