I’m running Caddy from Windows 10 Pro as a Reverse Proxy. Trying to figure out how to add a log to my Caddy file so I can self audit who connects to my server.
a. System environment:
OS, relevant versions, systemd? Docker? etc.
Windows 10 Pro where I have Caddy V2 and Emby Server installed.
b. Command:
Caddy Run via a caddy.bat file to automatically start as a Windows Service
nssm start Caddy
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
{
email myemail@domain.com
}
junipermedia.net {
reverse_proxy http://192.168.0.200:80
}
DO NOT REDACT anything except credentials
3. The problem I’m having:
My caddy file (without trying to add the log) was working fine. But now I’m trying to incorporate this example someone else is using to do the same thing, but I believe I keep messing up the Opening & Closing Brackets. Here is the example of what I’m trying to incorporate:
{
email myemail@domain.com
}
junipermedia.net {
reverse_proxy http://192.168.0.200:80
{
encode gzip
log {
output file C:\caddy\logs\emby_access.log {
roll true # Rotate logs, enabled by default
roll_size_mb 5 # Set max size 5 MB
roll_gzip true # Whether to compress rolled files
roll_local_time true # Use localhost time
roll_keep 2 # Keep at most 2 log files
roll_keep_days 7 # Keep log files for 7 days
}
4. Error messages and/or full log output:
I keep getting an error about gzip. Should I remove gzip? Are my brackets messed up?.
Please use ``` on lines before and after your config, it preserves whitespace and makes it easier to read. I went ahead and edited your post with that change.
You’re on the right track, the brackets are the issue. Every { should have a matching } to close a block.
Please read the Caddyfile structure docs, it should explain to you what you’re doing wrong:
What Francis was getting at was that you need to close your brackets. Your original file has a close bracket for every open bracket. Your new file is missing some close brackets.
Thank you…that wasn’t clear to me, but since I’m new to Caddy, it doesn’t surprise me. I’ve reviewed the Caddyfile Concept Structure that Francis recommended, but I’m still not completely getting it.
Can someone please help me clean-up my attempt at a Caddyfile. I feel confident with the top portion down with the closing bracket after “reverse_proxy…”, but the encode & logging lines are throwing me off. I thought this “might” be right, but still getting errors “Caddyfile 14”
Any help would be appreciated.
{
email myemail@domain.com
}
junipermedia.net {
reverse_proxy http://192.168.0.200:80
}
encode gzip {
log
output file C:\caddy\logs\emby_access.log }
{
roll true # Rotate logs, enabled by default
roll_size_mb 5 # Set max size 5 MB
roll_gzip true # Whether to compress rolled files
roll_local_time true # Use localhost time
roll_keep 2 # Keep at most 2 log files
roll_keep_days 7 # Keep log files for 7 days
}
junipermedia.net {
log {
output file C:\caddy\logs\emby_access.log {
roll_size 5MiB # Set max size 5 MB
roll_keep 2 # Keep at most 2 log files
roll_keep_for 96h # Keep log files for 4 days
}
}
reverse_proxy 192.168.0.200:80
}
I don’t see a roll_gzip in the log section of the documents so I left it off. Also in the docs the days for keeping logs it’s roll_keep_for and it’s in hours not days.
roll_size_mb is also labeled as roll_size in the docs and the 5 should be 5MiB. I hope that helps.