Madushan Pathirana
09/17/2025, 2:11 PMMarvin
09/17/2025, 2:11 PMMarvin
09/17/2025, 2:17 PM[server.api]
host = "0.0.0.0"
port = 4200
base_path = "/api"
csrf_protection_enabled = true
cors_allowed_origins = "<https://ui.your-domain.com>"
[server.ui]
enabled = true
serve_base = "/"
api_url = "<https://ui.your-domain.com/api>"
[ui]
url = "<https://ui.your-domain.com>"
Workers (task definition env) use the internal endpoint:
PREFECT_API_URL=<http://internal-prefect-api.your-vpc.local/api>
Notes:
- WebSockets/log streaming: ALB supports WebSockets. Ensure idle timeouts are high enough and no auth prompts interfere with ws under /api.
- This keeps your public surface area protected by OIDC while workers bypass auth via the internal LB.
Option 2: Single public ALB -> NGINX reverse proxy that enforces login and injects API auth
Goal: One public endpoint; NGINX handles user login and lets UI call the API; API requires a shared secret for all non-proxied clients.
- Public ALB
- Just forwards traffic to an NGINX service (sidecar or separate ECS service).
- NGINX
- Enforce OIDC with oauth2-proxy (or nginx-openidc) for all UI paths.
- For requests to /api from authenticated users, inject a Basic Authorization header with your Prefect API auth secret so the UI can call the API.
- Prefect config
- Enable Prefect API auth string so only clients with the secret can call the API.
- Workers set the same auth string in their environment.
Prefect settings:
[server.api]
host = "0.0.0.0"
port = 4200
base_path = "/api"
csrf_protection_enabled = true
auth_string = "admin:supersecret" # store securely
[server.ui]
enabled = true
serve_base = "/"
api_url = "<https://ui.your-domain.com/api>"
[ui]
url = "<https://ui.your-domain.com>"
Worker env:
PREFECT_API_URL=<https://ui.your-domain.com/api>
PREFECT_API_AUTH_STRING=admin:supersecret
NGINX sketch (with oauth2-proxy) that injects the header for UI-originated API calls:
```
# OIDC gate for UI and API
location /oauth2/ {
proxy_pass http://oauth2-proxy;
}
# UI
location / {Marvin
09/17/2025, 2:17 PM