{$DOMAIN} {
	encode zstd gzip
	header {
		Strict-Transport-Security "max-age=31536000"
		-Server
	}
	reverse_proxy app:8080 {
		flush_interval -1
	}
	# If Alaya can't answer (restarting, updating, or a fault): open screens get a JSON answer and show a banner,
	# and new visitors get a page that checks again every 30 seconds.
	handle_errors {
		@down_api {
			expression `{err.status_code} in [502, 503, 504]`
			path /api/*
		}
		@down expression `{err.status_code} in [502, 503, 504]`
		handle @down_api {
			header Content-Type application/json
			header Cache-Control no-store
			respond `{"code":"outage","message":"Alaya is having a problem right now."}` 503
		}
		handle @down {
			root * /srv/alaya-outage
			rewrite * /outage.html
			header Cache-Control no-store
			file_server
		}
	}
}
