# electro4ort's sites for the server's Caddy, which mounts this file among its
# sites (/etc/caddy/sites/electro4ort.caddy), gets the TLS certificates and
# reaches the services over the shared "web" network.
#
# The names are written out because that Caddy doesn't read this project's
# .env; they must match DOMAIN there, and all three must point at the server.
# The snippet is named after the project because every site file shares one
# namespace.
(electro4ort) {
	encode zstd gzip
	header {
		Strict-Transport-Security "max-age=31536000; includeSubDomains"
		-Server
	}
}

# The web app.
electro4ort.com.ua {
	import electro4ort
	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 electro4ort-web:3000
}

# The API and its socket. It sets its own security headers.
api.electro4ort.com.ua {
	import electro4ort
	reverse_proxy electro4ort-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.electro4ort.com.ua {
	import electro4ort
	reverse_proxy electro4ort-livekit:7880
}
