1. Caddy version (caddy version
):
2.3.0
2. How I run Caddy:
a. System environment:
baremetal
ubuntu 18.04
systemd
b. Command:
systemctl start caddy
c. Service/unit/compose file:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
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:
{
debug
local_certs
}
a.foobar.com:43001 {
respond "a"
}
b.foobar.com:43002 {
respond "b"
}
3. The problem I’m having:
I would like to have a custom reponse instead of empty 200 OK for curl like that :
curl https://a.foobar.com:43002/ -v -k
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to a.foobar.com (127.0.0.1) port 43002 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: [NONE]
* start date: Jun 1 12:10:40 2021 GMT
* expire date: Jun 2 00:10:40 2021 GMT
* issuer: CN=Caddy Local Authority - ECC Intermediate
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f82c800d600)
> GET / HTTP/2
> Host: a.foobar.com:43002
> User-Agent: curl/7.64.1
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 200
< server: Caddy
< content-length: 0
< date: Tue, 01 Jun 2021 13:23:38 GMT
<
* Connection #0 to host a.foobar.com left intact
* Closing connection 0
4. Error messages and/or full log output:
None, even with debug flag on
5. What I already tried:
add this at the end of caddyfile
:43001 {
respond 404
}
but got error:
loading http app module: provision http: getting tls app: loading tls app module: tls: invalid configuration: automation policy 1 is the second policy that acts as default/catch-all, but will never be used
6. Links to relevant resources:
Found similar issues, but workaround does’nt work in my case.