1. Output of caddy version
:
v2.6.0 h1:lHDynvM+sTOi9Aq4Y15b4FtkqzPB36WbUrZvVdwzTCA=
With Plugins
caddy-dns/cloudflare
caddyserver/transform-encoder
2. How I run Caddy:
as a service to check if caddy is running if not start it
a. System environment:
Windows 11
b. Command:
caddy run
d. My complete Caddy config:
(theheaders) {
header X-Content-Type-Options "nosniff"
header X-Xss-Protection "1; mode=block"
header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
header Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
header Pragma "no-cache"
header X-Frame-Options "SAMEORIGIN"
header Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(self), camera=(), encrypted-media=(), fullscreen=(self), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(*), speaker=(), sync-xhr=(), usb=(), vr=()"
header X-Robots-Tag "none"
header Access-Control-Max-Age "86400"
header /* {
-Server
}
}
:80 {
log {
format transform [{ts}] - User={user_id} - X-Forwarded-For={request>headers>X-Forwarded-For} - remote_ip={request>remote_ip} Country={request>headers>Cf-Ipcountry} {request>method} {request>headers>X-Forwarded-Proto} {request>host} {request>uri} {request>headers>Referer>[0]} {request>headers>User-Agent>[0]} - {request>proto} {status} {size} - {
#{request>headers} <--- add this if you want full log
time_format "02/Jan/2006 15:04:05 -0700"
}
output file C:\Users\wazer\Desktop\caddy\newnotworks\logs\domain.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
}
}
#SSL Settings
tls testdummy@nonodummy.org {
resolvers 1.1.1.1
}
import theheaders
#header X-Real-IP {http.request.header.CF-Connecting-IP}
#header X-Forwarded-For {http.request.header.CF-Connecting-IP}
#header X-Forwarded-Host {http.request.hostport}
encode gzip
@blocked {
#Only allow user-agents specified below and block everything else
not header_regexp User-Agent (?i:UserAgent1*|UserAgent2*)
#Allow lan ip's to skip user-agents block
not remote_ip private_ranges
#Allow wan ip's to skip user-agents block
#not remote_ip forwarded WAN_IP
}
handle @blocked {
abort
}
@UserAgent1 {
not remote_ip private_ranges
#not remote_ip forwarded WAN_IP
#Check if useragent is valid below then handle them correct file
header_regexp User-Agent (?i:UserAgent1*)
}
@UserAgent1LAN {
remote_ip private_ranges
#remote_ip forwarded WAN_IP
header_regexp User-Agent (?i:UserAgent1*)
}
@UserAgent2 {
not remote_ip private_ranges
#not remote_ip forwarded WAN_IP
#Check if useragent is valid below then handle them correct file
header_regexp User-Agent (?i:UserAgent2*)
}
@UserAgent2LAN {
remote_ip private_ranges
#remote_ip forwarded WAN_IP
header_regexp User-Agent (?i:UserAgent2*)
}
handle {
@public {
#Allow lan ip's to skip basicAuth
#not remote_ip private_ranges
#Allow wan ip found in forwarded header skip basicAuth
#not remote_ip forwarded WAN_IP
}
basicauth @public {
#Works with 2.5.5 caddy
#dummy JDJhJDE0JDJ0REF2N2IyWUZ4cE96U1llbFdaVWVBdlZqbzlFb1I3MWVxMXRwdzM5QTNhOGdXRVZCbGVH # username and password is dummy
#Works with caddy 2.6.0 and so on
dummy $2a$14$xunbzZrcuN3HS0y.oBQzr.YuCtRG.aC9xNyKRvOZa2p41R3Py7n7W # username and password is dummy
}
handle @UserAgent1 {
# reads from @UserAgent1
handle_path /testout
root * C:\Users\wazer\Desktop\caddy\newnotworks\files\testout.xml
file_server browse
rewrite * /testout
}
handle @UserAgent1LAN {
# reads from @UserAgent1LAN
handle_path /testin
root * C:\Users\wazer\Desktop\caddy\newnotworks\files\testin.xml
file_server browse
rewrite * /testin
}
handle @UserAgent2 {
# reads from @UserAgent2
handle_path /testoutrec
root * C:\Users\wazer\Desktop\caddy\newnotworks\files\testoutrec.xml
file_server browse
rewrite * /testoutrec
}
handle @UserAgent2LAN {
# reads from @UserAgent2LAN
handle_path /testinrec
root * C:\Users\wazer\Desktop\caddy\newnotworks\files\testinrec.xml
file_server browse
rewrite * testinrec
}
handle_path /test2 {
root * C:\Users\wazer\Desktop\caddy\newnotworks\files\test2.xml
file_server browse
}
}
}
3. The problem I’m having:
Getting responds 200 on files but 0 bytes ?
5. What I already tried:
I thought it was first because of the new basic auth syntax with hash-password being changed so I changed that, I also tried removing checks for ip and user-agents, with same result.
Rolling back to version 2.5.2 and it works again?
v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=
With Plugins
caddy-dns/cloudflare
caddyserver/transform-encoder
What am I missing here in the changes to migrate this over to latest version?