Need help with log

Hello,

I’m currently testing Caddy because I’m considering switching from the nginx proxy manager to caddy.
I’ve already successfully set up my first reverse proxy.

However, I fail to see the access to the reverse proxy in the log.

About my system:

Caddy was installed via Apt according to the instructions.

My Caddyfile:

{
    log {
        output file /var/log/caddy/access.log
        format json
    }
}

abc.def.gh {
    reverse_proxy 192.168.99.83:3001
}

The log was also created and filled. But I don’t see any access to the proxy URL.

Die letzten Zeilen aus dem log:

{"level":"info","ts":1724176310.1634257,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//[::1]:2019","//127.0.0.1:2019","//localhost:2019"]}
{"level":"info","ts":1724176310.1635413,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
{"level":"info","ts":1724176310.1635644,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1724176310.1637213,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
{"level":"info","ts":1724176310.1638103,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
{"level":"info","ts":1724176310.16383,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
{"level":"info","ts":1724176310.1638412,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["xxxxxx x.com"]}
{"level":"info","ts":1724176310.1703248,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00021fe30"}
{"level":"info","ts":1724176310.1703625,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
{"level":"info","ts":1724176310.1707323,"logger":"tls","msg":"finished cleaning storage units"}
{"level":"info","ts":1724176310.1710637,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
{"level":"info","ts":1724176310.171839,"msg":"serving initial configuration"}

Probably a stupid mistake on my part?

The log global options configures Caddy’s runtime (not HTTP access) logs. For access logs, you use the log directive within the site block. The docs for the log directive are here:

You’re looking for something like this

abc.def.gh {
    log {
        output file /var/log/caddy/access.log
        format json
    }
    reverse_proxy 192.168.99.83:3001
}

But ensure that’s really what you need by reading the linked page and amending the config accordingly.

1 Like

Thank you very much.
Now it makes sense.

I’ve already seen the help page, but my poor English and the new topic make it a bit difficult…

Can you tell me how I log unassigned subdomains? I would prefer to get a 404 if I go to unassigned.mysite.com.

I tried that:

handle *.xxx.com {
respond 404
}

*.graef.xxx.com {
respond /health-check 404
}

.xxx.com. {
respond /secret/
“Access denied” 403 {
close
}
}

This shows you have a knowledge gap in terms of how to configure Caddy with Caddyfile. I strongly recommend you go through these pages:

Ultimately, to do what you intend to do, you have to accept the connection on plain HTTP and reject it from there. Another way is to get a wildcard certificate, then do a match on the accepted hosts but fall-through to 404 for unrecognized subdomains.

1 Like

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