1. My Caddy version (caddy version
):
v2.0.0-rc.3 h1:z2H/QnaRscip6aZJxwTbghu3zhC88Vo8l/K57WUce4Q=
2. How I run Caddy:
caddy act as https reverse proxy for a spring api server
a. System environment:
running on docker 19.03.8 on ubuntu 18.04
b. Command:
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
d. My complete Caddyfile or JSON config:
#{
#admin localhost:2019
#}
localhost:443 {
reverse_proxy backend:8080
tls internal
log {
output file /var/log/access.log {
roll_size 1gb
roll_keep 5
}
}
handle_errors {
@404 {
expression int({http.error.status_code}) == 404
# expression {http.error.status_code} == '404'
}
respond @404 "Oops 404 Try again"
}
}
3. The problem I’m having:
I was expeting to see Oops Try again when getting non existing address
i.e:
$ curl -k https://localhost/nonexists
{"timestamp":"2020-04-25T15:15:44.247+0000","status":404,"error":"Not Found","message":"No message available","path":"/nonexists"}
(this message is exactly the same when I curl http without passing trough caddy proxy)
4. Error messages and/or full log output:
and the log from caddy and /var/log/access.log
2020/04/25 15:15:44.249 ERROR http.log.access.log0 handled request {“request”: {“method”: “GET”, “uri”: “/nonexists”, “proto”: “HTTP/2.0”, “remote_addr”: “172.23.0.1:51462”, “host”: “localhost”, “headers”: {“User-Agent”: [“curl/7.58.0”], “Accept”: [“/”]}, “tls”: {“resumed”: false, “version”: 772, “ciphersuite”: 4865, “proto”: “h2”, “proto_mutual”: true, “server_name”: “localhost”}}, “common_log”: “172.23.0.1 - - [25/Apr/2020:15:15:44 +0000] "GET /nonexists HTTP/2.0" 404 130”, “latency”: 0.006254959, “size”: 130, “status”: 404, “resp_headers”: {“Vary”: [“Origin”, “Access-Control-Request-Method”, “Access-Control-Request-Headers”], “Content-Type”: [“application/json”], “Date”: [“Sat, 25 Apr 2020 15:15:44 GMT”], “Server”: [“Caddy”]}}
5. What I already tried:
expression {http.error.status_code} == ‘404’
I wish caddy serve my 404.html page, but I am tring to do handle the error first (and then try to with file-server/rewrite if needed…)
I tried already this (with no luck)
can you help me or point to the right documentation please?