# /etc/caddy/Caddyfile
(capacic) {
	log {
		output file C:/Users/{{user}}/scoop/apps/git/current/etc/caddy/caddy.log
	}
	root * C:/Users/{{user}}/scoop/apps/git/current/etc/caddy/html
	encode zstd gzip
	request_body {
		max_size 500MB
	}
	file_server {
		# If we visit /404.html directly we receive a 404 response, and not a 200.
		hide 404.html
		browse
		precompressed zstd gzip br
	}
	handle_errors {
		# https://caddyserver.com/docs/v2-upgrade#errors
		@404 {
			expression {http.error.status_code} == 404
		}
		rewrite @404 /404.html
		file_server
	}
	handle /api/send {
		reverse_proxy localhost:5959
	}
	handle /rest/nc/* {
		reverse_proxy localhost:5959
	}
	handle /rest/nw/* {
		reverse_proxy localhost:5959
	}
	handle /rest/ma/* {
		reverse_proxy localhost:5955
	}
	handle /nc/* {
		try_files {path} {path}/ {path}/index.html /nc/
	}
	handle /nw/* {
		try_files {path} {path}/ {path}/index.html /nw/
	}
	handle /ma/* {
		try_files {path} {path}/ {path}/index.html /ma/
	}
	handle {
		try_files {path} {path}/ {path}/index.html / # remove last / if you want to show 404.html on error
	}
}

{{domain}} {
	# Set this path to your site's directory.
	import capacic
	tls {
		dns cloudflare {{cloudflare_key}}
	}
}
