Linked List

A personal knowledge base

Varnish

#Ban a URL in Varnish 4

varnish> ban req.url == "/pages"
varnish> ban req.http.host == "linkedlist.org" && 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 req.http.host == "linkedlist.org" && 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:.*59.167.123.145.*'
varnishlog -c -m ReqStart:'59.167.123.145'
Last modified: 12 Jan 2016