# OpenViking reverse proxy — legacy fallback
#
# Port 1934 is retained only as a legacy entrypoint for existing deployments
# that already reference it. Its primary remaining purpose is as the upstream
# target for a TLS-terminating proxy (e.g. HTTPS via Caddy domain block).
#
# For new deployments, connect directly to the OV server on
# OPENVIKING_SERVER_PORT (1933 by default). With the gateway Compose
# profile, this is also the entrypoint for gateway clients: the gateway port
# is not published and the block below routes its paths.
# Web Studio is served by OV itself at /studio — no separate proxy needed.
#
# To add public HTTPS, append a domain block below (Caddy auto-provisions
# Let's Encrypt certs):
#
#   {$OPENVIKING_PUBLIC_BASE_URL} {
#       # OpenViking Gateway paths; keep them in sync with the :1934 block below.
#       @gateway path /v1/* /api/v3/* /api/compatible/v1/* /gateway/uploads
#       handle @gateway {
#           reverse_proxy gateway:1935 {
#               flush_interval -1
#           }
#       }
#       handle {
#           reverse_proxy openviking:{$OPENVIKING_SERVER_PORT:1933}
#       }
#       # Optional: pin ACME email
#       # tls {$OV_ACME_EMAIL}
#   }
#
# Then expose ports 80/443 in docker-compose.yml and set
# OPENVIKING_PUBLIC_BASE_URL=https://your-domain.com in .env.

:1934 {
	@gateway path /v1/* /api/v3/* /api/compatible/v1/* /gateway/uploads
	handle @gateway {
		reverse_proxy gateway:1935 {
			flush_interval -1
		}
	}
	handle {
	reverse_proxy openviking:{$OPENVIKING_SERVER_PORT:1933}
	}
}
