# Orbtrace edge reverse proxy.
#
# Orbtrace ships product, not ingest. There is no OTLP route here —
# customers run their own OpenTelemetry Collector (existing pipeline or
# a docker run; see `docs/integration-patterns.md`). Their Collector
# writes directly to `doris-fe:8030` via the Doris Stream Load endpoint;
# Caddy only fronts the UI + REST surface.
#
# Replace example domains with the real ones before going live. Most
# deployments need only ONE site block — delete the second unless you
# split UI and API hostnames.
#
# TLS options:
#   * Public DNS + reachable 80/443 → Caddy auto-provisions Let's Encrypt;
#     nothing to configure.
#   * Internal CA (the regulated-network default): mount your cert/key
#     into the container and add a `tls` directive inside the site block:
#
#         your-host.bank.internal {
#             tls /etc/caddy/certs/orbtrace.pem /etc/caddy/certs/orbtrace.key
#             ...
#         }
#
#     with the mount added under the caddy service in docker-compose.yml:
#         - ./certs:/etc/caddy/certs:ro
#
# Topology:
#   demo.orbtrace.com   →  Orbtrace (UI + REST)      on orbtrace:8080
#   api.orbtrace.com    →  Orbtrace (REST only)      on orbtrace:8080

demo.orbtrace.com {
    encode zstd gzip
    # Astra streams SSE on POST /api/astra/messages/stream. Caddy
    # buffers reverse-proxy responses by default, which would hold
    # token deltas in 8 KiB chunks until either the buffer fills or
    # the upstream closes — destroying the "watch the reply land
    # token by token" UX. flush_interval -1 disables the buffer for
    # this route. We scope it to the streaming path so non-streaming
    # JSON responses keep the default coalescing behaviour. The
    # broader path matcher also covers any future SSE endpoint
    # (alert evaluations, replay progress) without needing another
    # tweak per route.
    @sse path /api/astra/messages/stream*
    reverse_proxy @sse orbtrace:8080 {
        flush_interval -1
    }
    reverse_proxy orbtrace:8080
}

api.orbtrace.com {
    encode zstd gzip
    @sse path /api/astra/messages/stream*
    reverse_proxy @sse orbtrace:8080 {
        flush_interval -1
    }
    reverse_proxy orbtrace:8080
}

