Technotes

Technotes for future me

varnishlog

Check header:

varnishlog -q 'ReqHeader ~ "Host: www.google.com"' -g session

Check user agent:

varnishlog -g request  -q 'ReqHeader ~ "user-agent: blaataap"' -g session

Filter by request host header

varnishlog -q 'ReqHeader ~ "Host: example.com"'

Filter by request url

varnishlog -q 'ReqURL ~ "^/some/path/"'
varnishlog -q 'ReqURL ~ "^/"'
varnishlog -q 'ReqURL !~ "^/status"'

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:"

Show backend responses

varnishlog -g request -q "RespStatus eq 503"

varnishlog -g request -q "BerespStatus eq 503"

Show HTTP requests

varnishlog -q "ReqMethod eq PURGE"

Show HTTP purges

varnishlog -q "VCL_return eq purge"
Last updated on 31 Jan 2021
Published on 11 Dec 2019
Edit on GitHub