Skip to main content

Reverse Proxy (Replace Content)

https://github.com/caddyserver/replace-response

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

new.example.com {
tls user@example.com

log {
	output file /var/log/caddy/caddy.log
}

route {
	replace old.example.com new.example.com
	reverse_proxy https://old.example.com {
		header_up Host old.example.com
		header_up Accept-Encoding identity
		header_down Location old.example.com new.example.com
		header_down Access-Control-Allow-Origin old.example.com new.example.com

		transport http {
			tls
			tls_server_name old.example.com
			tls_insecure_skip_verify
		}
	}
}

encode zstd gzip

}

*
  • { redir https://new.example.com }
  • #
Refer to the Caddy docs for more information: # https://caddyserver.com/docs/caddyfile