{
	email {$CADDY_EMAIL:marvin.krausser277@gmail.com}
}

(common) {
	encode zstd gzip
	header {
		Strict-Transport-Security "max-age=31536000; includeSubDomains"
		X-Content-Type-Options "nosniff"
		Referrer-Policy "strict-origin-when-cross-origin"
		-Server
	}
	log
}

marvinkrausser.com {
	import common
	reverse_proxy cnn_website:8080
}

api.marvinkrausser.com {
	import common
	request_body {
		max_size {$CADDY_MAX_BODY_API:16MB}
	}
	reverse_proxy cnn_api:8000
}

portfolio.marvinkrausser.com {
	import common
	reverse_proxy portfolio_website:8081
}

git.marvinkrausser.com {
	import common
	reverse_proxy gitea:3000
}

game.marvinkrausser.com {
	import common

	# /wizard and /wizard/website -> /wizard/website/ so relative asset paths resolve
	redir /wizard /wizard/website/ permanent
	redir /wizard/ /wizard/website/ permanent
	redir /wizard/website /wizard/website/ permanent

	# The prefixes are stripped, so the backends see "/..." instead of
	# "/wizard/api/..." or "/wizard/website/...".
	@wizard_api path /wizard/api /wizard/api/*
	handle @wizard_api {
		uri strip_prefix /wizard/api
		reverse_proxy wizard_server:8083
	}

	handle_path /wizard/website/* {
		reverse_proxy wizard_website:8082
	}

	# handle_path strips the prefix, so the backends see "/..." only.
	handle_path /actionblocks/website /actionblocks/website/* {
		reverse_proxy actionblocks-website:80
	}

	handle_path /actionblocks/server /actionblocks/server/* {
		reverse_proxy actionblocks-server:8080
	}

	handle {
		respond 404
	}
}

cloud.marvinkrausser.com {
    reverse_proxy nextcloud-nextcloud-1:80

    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301

    header Strict-Transport-Security "max-age=15552000; includeSubDomains"
}
