1. Caddy version (caddy version
): V2
2. How I run Caddy:
a. System environment:
Docker official :latest
image
b. Command:
c. Service/unit/compose file:
caddy:
image: caddy
container_name: caddy
volumes:
- /etc/docker/data/caddy/Caddyfile:/etc/caddy/Caddyfile
- /etc/docker/data/caddy/data:/data
- /etc/docker/data/caddy/config:/config
ports:
- 80:80
- 443:443
- 2015:2015
environment:
- ACME_AGREE=true
restart: unless-stopped
d. My complete Caddyfile or JSON config:
{
admin 0.0.0.0:2015
email w@swtk.info
# acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}
(netMatchers) {
@internet {
not remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16
}
@local {
remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16
}
}
# LAN connection, unavailable from outside
(lanCore) {
log {
level ERROR
format single_field common_log
}
@internet {
not remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16
}
@local {
remote_ip 192.168.10.0/24 192.168.20.0/24 172.19.0.0/16
}
respond @internet 200
}
(lan) {
import lanCore
reverse_proxy @local {args.0}
}
(lan-skip-insecure) {
import lanCore
reverse_proxy @local {args.0} {
transport http {
tls
tls_insecure_skip_verify
}
}
}
# internet connection
(internet) {
log {
level ERROR
}
reverse_proxy {args.0}
}
# hosts
https://deluge.XXX.eu {
import lan deluge:8112
}
3. The problem I’m having:
I expected that the configuration above will filter all logs below ERROR
for the site https://deluge.XXX.eu
. Indeed, when I connect to the site via my browser I do not see the connection logs.
When I connect via a program, however (specifically Python’s requests
- calling the same URL as above) I do get logs (they are below).
One of the logs is a full JSON one, and the other one just an access one. I wonder where the other one comes from - I know that this comes from a monitoring program I wrote and I see the logs for all sites that are monitored (such as the one in the example log), and then at the end that weird single line (in the same block of logs coming from the monitoring program)
4. Error messages and/or full log output:
{"level":"info","ts":1608739629.023793,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"172.19.0.1:41538","proto":"HTTP/1.1","method":"GET","host":"deluge.XXX.eu","uri":"/","headers":{"Accept":["*/*"],"Connection":["keep-alive"],"User-Agent":["python-requests/2.23.0"],"Accept-Encoding":["gzip, deflate"]}},"common_log":"172.19.0.1 - - [23/Dec/2020:16:07:09 +0000] \"GET / HTTP/1.1\" 308 0","duration":0.000042132,"size":0,"status":308,"resp_headers":{"Server":["Caddy"],"Location":["https://deluge.XXX.eu/"],"Connection":["close"],"Content-Type":[]}}
172.19.0.1 - - [23/Dec/2020:16:07:09 +0000] "GET / HTTP/1.1" 405 178
5. What I already tried:
I looked very much at the docs, then at the configuration, then at the logs again and then decided to post the question here