Skip to content

Instantly share code, notes, and snippets.

@iamdylanngo
Created March 25, 2020 09:35
Show Gist options
  • Select an option

  • Save iamdylanngo/06869ab08e1575b655879c2d9ff2d1fa to your computer and use it in GitHub Desktop.

Select an option

Save iamdylanngo/06869ab08e1575b655879c2d9ff2d1fa to your computer and use it in GitHub Desktop.
varnish-centos-log.readme
# Varnish log
varnishlog -a -A -w /var/log/varnish/varnish50x.log -q "RespStatus >= 500 or BerespStatus >= 500" &
@iamdylanngo
Copy link
Author

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

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