1. Caddy version (caddy version
):
v2.2.1
2. How I run Caddy:
Caddy installed via apt-get (Ubuntu)
Using a Caddyfile
a. System environment:
Ubuntu 18
b. Command:
sudo caddy run
d. My complete Caddyfile or JSON config:
mysite.co.uk {
handle /.well-known/pki-validation/* {
root * /home/ubuntu/pki-validation/
file_server {
index index.txt
}
}
redir https://www.mysite.co.uk{uri} 302
}
3. The problem I’m having:
We use Caddy as a simple redirect server - redirecting requests for non-www domains to www domains that are hosted elsewhere (for Cloudfront reasons).
This all works fine.
However, I want requests for http://mysite.co.uk/.well-known/pki-validation/VALIDATIONCODE.txt
to not be redirected and to remain on http and non-www.
I thought maybe the best way of accomplishing this was to serve a static file inside the Caddy server /home/ubuntu/pki-validation/index.txt
but I couldn’t seem to get this working - it still ends up redirecting to https://www.mysite.co.uk/.well-known/pki-validation/VALIDATIONCODE.txt
Any pointers would be greatly appreciated.
Thanks
5. What I already tried:
Initially I tried without the handle
directive and had something like:
mysite.co.uk {
file_server /.well-known/pki-validation/VALIDATIONCODE.txt {
root /home/ubuntu/pki-validation/
index index.txt
}
redir https://www.mysite.co.uk{uri} 302
}
with no luck