Wildcard log isn't working

1. The problem I’m having:

Trying to log with a wildcard doesn’t work. Single domains work fine.

2. Error messages and/or full log output:

No errors.

Docker logs:

{"level":"debug","ts":1704450016.6151938,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"trilium:8080","duration":0.003094674,"request":{"remote_ip":"172.70.91.161","remote_port":"37810","client_ip":"REDACTED","proto":"HTTP/2.0","method":"GET","host":"notes.jackbailey.uk","uri":"/login","headers":{"Cdn-Loop":["cloudflare"],"Sec-Ch-Ua":["\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\""],"Accept-Language":["en-GB,en-US;q=0.9,en;q=0.8"],"Priority":["u=0, i"],"Cf-Visitor":["{\"scheme\":\"https\"}"],"Sec-Fetch-User":["?1"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"macOS\""],"X-Forwarded-For":["REDACTED, REDACTED"],"X-Forwarded-Host":["notes.jackbailey.uk"],"Sec-Fetch-Mode":["navigate"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"Sec-Fetch-Site":["none"],"Sec-Fetch-Dest":["document"],"Cf-Ipcountry":["GB"],"Accept-Encoding":["gzip"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"],"X-Forwarded-Proto":["https"],"Cf-Ray":["840afcdbde10417c-LHR"],"Cookie":[],"Cf-Connecting-Ip":["REDACTED"],"Cache-Control":["max-age=0"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"notes.jackbailey.uk"}},"headers":{"X-Xss-Protection":["0"],"Content-Type":["text/html; charset=utf-8"],"Vary":["Accept-Encoding"],"Referrer-Policy":["no-referrer"],"X-Dns-Prefetch-Control":["off"],"Strict-Transport-Security":["max-age=15552000; includeSubDomains"],"X-Permitted-Cross-Domain-Policies":["none"],"Origin-Agent-Cluster":["?1"],"X-Frame-Options":["SAMEORIGIN"],"Etag":["W/\"a1b-f6zSl2nUuYUxOeZlTjaLrfoGcqk\""],"Connection":["keep-alive"],"Cross-Origin-Opener-Policy":["same-origin"],"Cross-Origin-Resource-Policy":["same-origin"],"X-Download-Options":["noopen"],"Content-Encoding":["gzip"],"Date":["Fri, 05 Jan 2024 10:20:16 GMT"],"Keep-Alive":["timeout=600"],"X-Powered-By":["Express"],"X-Content-Type-Options":["nosniff"]},"status":200}

/srv/logs/caddy.log:

{"level":"info","ts":1704449887.1875165,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"172.70.46.4","remote_port":"64016","client_ip":"REDACTED","proto":"HTTP/2.0","method":"GET","host":"invoices.jackbailey.dev","uri":"/","headers":{"Cf-Visitor":["{\"scheme\":\"https\"}"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0"],"Referer":["http://invoices.jackbailey.dev/"],"Cf-Connecting-Ip":["REDACTED"],"Accept-Encoding":["gzip"],"Cf-Ray":["840af9b1ad550eb3-AMS"],"X-Forwarded-Proto":["https"],"Cdn-Loop":["cloudflare"],"Cf-Ipcountry":["NL"],"X-Forwarded-For":["REDACTED"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"invoices.jackbailey.dev"}},"bytes_read":0,"user_id":"","duration":0.13303074,"size":637,"status":200,"resp_headers":{"Server":["Caddy","nginx"],"Alt-Svc":["h3=\":443\"; ma=2592000"],"Cache-Control":["no-cache, private"],"Date":["Fri, 05 Jan 2024 10:18:07 GMT"],"Set-Cookie":[],"Content-Encoding":["gzip"],"Content-Type":["text/html; charset=UTF-8"]}}
{"level":"info","ts":1704449887.2883847,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"172.70.46.128","remote_port":"42548","client_ip":"REDACTED","proto":"HTTP/2.0","method":"GET","host":"invoices.jackbailey.dev","uri":"/favicons/favicon-32x32.png","headers":{"Cdn-Loop":["cloudflare"],"Cf-Ipcountry":["NL"],"X-Forwarded-For":["REDACTED"],"Cf-Ray":["840af9b32f510eb3-AMS"],"Cookie":[],"Cf-Connecting-Ip":["REDACTED"],"Accept-Encoding":["gzip"],"X-Forwarded-Proto":["https"],"Cf-Visitor":["{\"scheme\":\"https\"}"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"invoices.jackbailey.dev"}},"bytes_read":0,"user_id":"","duration":0.000532058,"size":1490,"status":200,"resp_headers":{"Server":["Caddy","nginx"],"Alt-Svc":["h3=\":443\"; ma=2592000"],"Accept-Ranges":["bytes"],"Date":["Fri, 05 Jan 2024 10:18:07 GMT"],"Last-Modified":["Sun, 06 Mar 2022 07:09:21 GMT"],"Cache-Control":["max-age=315360000"],"Content-Type":["image/png"],"Content-Length":["1490"],"Expires":["Thu, 31 Dec 2037 23:55:55 GMT"]}}

3. Caddy version:

v2.7.4

4. How I installed and ran Caddy:

Custom Dockerfile - caddy-image/Dockerfile at main · JackBailey/caddy-image · GitHub

a. System environment:

unRAID 6.12.3 running Docker

d. My complete Caddy config:

{
        debug
        email REDACTED
        servers {
                trusted_proxies static 172.21.0.0/16 100.64.0.0/10
                trusted_proxies cloudflare
        }

        dynamic_dns {
                provider cloudflare {$CF_TOKEN}
                domains {
                        jackbailey.uk *
                        jackbailey.dev invoices
                }
        }
}


(log) {
        log {
                output file /srv/logs/caddy.log {
                        roll_keep 30
                        roll_keep_for 720h # 30 days in hours
                        roll_interval 24h # Rotate logs every 24 hours
                }
                level INFO
                format json
        }
}

(cf_cert) {
        tls {
                dns cloudflare {$CF_TOKEN}
        }
}

(cf_only) {
        @non-cf {
                not dynamic_remote_ip cloudflare
                not dynamic_remote_ip static 10.30.3.0/24
        }
        abort @non-cf
}

invoices.jackbailey.dev {
        import cf_cert
        import cf_only
        import log
        reverse_proxy crater:80
}

*.jackbailey.uk {
        import cf_cert
        import cf_only
        import log

        @notes host notes.jackbailey.uk
        handle @notes {
                reverse_proxy trilium:8080
        }

        handle {
                respond 502 {
                        close
                }
        }
}

Please update to the latest version, v2.7.6

Oops sorry this is on 2.7.6, typo

I did some tests with your config and I can’t replicate the problem. Works for me :man_shrugging:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Since this was locked, @JackBailey wrote on Discord that their problem was that they had two extra sites in their config :80 and :443 which affected the behaviour.

We couldn’t replicate, because we weren’t given the entire config, only a part which didn’t exhibit the problem!