# DarkWire for the web on Caddy (gets its certificate by itself), with PHP-FPM for the push relay
# (relay.php, PHP 8.1 or newer). Put the files in /var/www/darkwire and adjust the domain and the
# PHP-FPM socket. Without PHP the page still works, but contacts on Chrome, Edge or Safari can't be
# reached from it (the page says so). The Docker image needs neither: it has PHP built in.

chat.example.org {
	root * /var/www/darkwire
	encode zstd gzip
	header {
		X-Content-Type-Options nosniff
		Referrer-Policy no-referrer
		X-Frame-Options DENY
		Permissions-Policy "camera=(self), microphone=(self), geolocation=()"
		-Server
	}
	# Always fresh: the page and its service worker decide which version runs.
	@fresh path / /index.html /sw.js /manifest.webmanifest
	header @fresh Cache-Control no-cache
	# Hashed file names: never change.
	header /assets/* Cache-Control "public, max-age=31536000, immutable"

	respond /relay-hosts.txt 404
	php_fastcgi /relay.php unix//run/php/php-fpm.sock
	file_server
}
