1. Caddy version (caddy version
):
v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=
2. How I run Caddy:
As a reverse proxy
a. System environment:
Ubuntu 18 LTS on EC2
b. Command:
./caddy start
d. My complete Caddyfile v 2.1.1 (v 0.10.2 Caddyfile is below):
:80 {
rewrite * /custom{uri}
reverse_proxy {
to targetdomain.com:80
header_up X-Custom-Domain {host}
}
log {
output stdout
}
}
:443 {
rewrite * /custom{uri}
reverse_proxy targetdomain.com:443 {
header_up X-Custom-Domain {host}
}
log {
output stdout
}
tls {
on_demand
}
}
3. The problem I’m having:
I have been using Caddy Server to auto-provision SSL certificates dynamically on all hosts and reverse proxy it to my final domain.
This is how the request has been routing on Caddy 0.10.2:
https://test.myserver.com/abc → https://targetdomain.com/custom/abc
https://alpha.charlie.com/xyz → https://targetdomain.com/custom/xyz
CaddyFile for 0.10.2 is this:
:80 {
root /var/www
gzip
proxy / http://targetdomain.com/custom {
header_upstream X-Custom-Domain {host}
}
}
:443 {
root /var/www
gzip
tls {
max_certs 1000
}
proxy / https://targetdomain.com/custom {
header_upstream X-Custom-Domain {host}
}
}
5. What I already tried:
I’ve tried various different Caddyfile 2.1.1 configurations but I’m not able to achieve the same results. We ask our users to point their domains to our Caddy server and generate their Let’s Encrypt certificates on-demand during the initial request.