# The one door from the internet: gets and renews the TLS certificates, and
# hands each name to its service. DOMAIN comes from .env beside
# docker-compose.yml; all three names must point at this server.
(common) {
	encode zstd gzip
	header {
		Strict-Transport-Security "max-age=31536000; includeSubDomains"
		-Server
	}
}

# The web app.
{$DOMAIN} {
	import common
	header {
		X-Content-Type-Options nosniff
		X-Frame-Options DENY
		Referrer-Policy strict-origin-when-cross-origin
		# Calls ask for these; nothing embedded in the page may.
		Permissions-Policy "camera=(self), microphone=(self), display-capture=(self), geolocation=()"
	}
	# Built files carry a hash of their content in their name.
	@built path /assets/*
	header @built Cache-Control "public, max-age=31536000, immutable"
	reverse_proxy web:3000
}

# The API and its socket. It sets its own security headers.
api.{$DOMAIN} {
	import common
	reverse_proxy api:3000
}

# Signalling for calls. The media itself doesn't pass through here: browsers
# send it straight to LiveKit, on the ports docker-compose.yml opens.
livekit.{$DOMAIN} {
	import common
	reverse_proxy livekit:7880
}
