1. My Caddy version (caddy version
):
v2.0.0-beta.14 h1:QX1hRMfTA5sel53o5SuON1ys50at6yuSAnPr56sLeK8=
2. How I run Caddy:
a. System environment:
- Ubuntu 18.04.4
- systemd 237
c. Service/unit/compose file:
[Unit]
Description=Caddy Web Server
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --config /etc/caddy/caddy.json --resume --environ
ExecReload=/usr/bin/caddy reload --config /etc/caddy/caddy.json
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
Caddyfile:
*.tryhexadecimal.com {
encode gzip zstd
reverse_proxy 0.0.0.0:3000 {
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Port {server_port}
header_up X-Forwarded-Proto {scheme}
}
}
And the equivalent JSON config:
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"*.tryhexadecimal.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"encodings": {
"gzip": {},
"zstd": {}
},
"handler": "encode"
},
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"X-Forwarded-For": [
"{http.request.remote.host}"
],
"X-Forwarded-Port": [
"{server_port}"
],
"X-Forwarded-Proto": [
"{http.request.scheme}"
]
}
}
},
"upstreams": [
{
"dial": "0.0.0.0:3000"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}
3. What I am trying to accomplish:
- Obtain a wildcard certificate. But first, I need to enable a DNS challenge.
- Issue certificates on demand.
Below is my hand-written JSON configuration (for tls
only, http
part of the config can be found above). I’d be grateful if you could give it a look to see if it needs improvement.
{
"apps": {
"tls": {
"automation": {
"on_demand": {
"ask": "MY WEBHOOK URL"
},
"policies": [{
"management": {
"module": "acme",
"email": "MY EMAIL",
"challenges": {
"dns": {
"provider": "cloudflare",
"api_token": "MY API TOKEN"
}
}
}
}]
}
}
}
}
Also, is there a way to store certificates on a remote file system (e.g. AWS EFS)?
4. Error messages and/or full log output:
{"error": "loading config: loading new config: loading app modules: module name 'tls': provision tls: loading TLS automation management module: loading module 'acme': provision tls.management.acme: loading DNS provider module: loading module 'cloudflare': unknown module: tls.dns.cloudflare", "status_code": 400}