Skip to content

Instantly share code, notes, and snippets.

@cupracer
Last active September 13, 2024 15:57
Show Gist options
  • Save cupracer/54f496a54b6ce65576b718be602f5d21 to your computer and use it in GitHub Desktop.
Save cupracer/54f496a54b6ce65576b718be602f5d21 to your computer and use it in GitHub Desktop.
varnishlog examples (version 4.x)
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header
varnishlog -q 'ReqHeader ~ "Host: (www\.)?example\.com"' -i "ReqURL" -I "ReqHeader:Referer:"
# filter for permanent redirects and show request host/url and new location
varnishlog -q "RespStatus ~ 301" -i "ReqURL" -I "ReqHeader:Host:" -I "RespHeader:Location:" -i "RespStatus"
# filter for permanent and temporary redirects and filter for Location "http://s3" to
# just show (for example) redirects to something on an Amazon S3 bucket
varnishlog -q '(RespStatus ~ 301 or RespStatus ~307) and RespHeader ~ "Location: https://s3"' \
-i "ReqURL" -I "ReqHeader:Host:" -I "RespHeader:Location:" -i "RespStatus" -I "ReqHeader:Referer:"
@abhisheksurve45
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment