# /etc/caddy/Caddyfile
(nadacode) {
	request_body {
		max_size 500MB
	}
	handle /rest/nc/* {
		reverse_proxy localhost:5959
	}
	handle /rest/nw/* {
		reverse_proxy localhost:5959
	}
	handle /rest/ma/* {
		reverse_proxy localhost:5955
	}
	handle {
		root * /etc/caddy/html
		try_files {path} {path}/ {path}/index.html index.html
		encode zstd gzip
		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
		}
		route /nc/* {
			try_files {path} {path}/ /nc/
		}
		route /nw/* {
			try_files {path} {path}/ /nw/
		}
		route /ma/* {
			try_files {path} {path}/ /ma/
		}
	}
	handle_errors {
		# https://caddyserver.com/docs/v2-upgrade#errors
		@404 {
			expression {http.error.status_code} == 404
		}
		rewrite @404 /404.html
		file_server
	}
}

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