Linked List

A personal knowledge base


#Ban a URL in Varnish 4

varnish> ban req.url == "/pages"
varnish> ban == "" && req.url == "/pages"

The operator can be one of ~, !~, == or != and the field can be anything accessible on req.

#Ban Based on Content Type

ban obj.http.content-type ~ html

#Ban Based on Host & Content Type

ban == "" && obj.http.content-type ~ html

#List Names of Running Varnish Processes

Useful for varnishlog -n

ls /var/lib/varnish/

#Log Requests Matching URL

varnishlog -g request -q 'ReqURL eq "/"'

or regex:

varnishlog -g request -q 'ReqURL ~ "something"'

#Log Requests for Specific IPs

The first one is for when there is a proxy in front of Varnish (E.g. HTTPS terminator).

varnishlog -c -m RxHeader:'X-Forwarded-For:.**'
varnishlog -c -m ReqStart:''
Last modified: 11 January 2016