Varnishncsa and std.log()

New in Varnish 3.0.3rc1 is that you can put arbitrary log lines from VCL into the varnishncsa output. This can be used for funky stuff like logging the session cookie along with the request.

Let’s say you have the following VCL and have a session id as the single site cookie:

import std;

sub vcl_deliver {

std.log(“sessionid:” + regsub(req.http.cookie, “.*=”, “”);

}

Run varnishncsa as follows:

 # varnishncsa -F ‘%h %l %u %t “%r” %s %b “%{Referer}i” “%{User-agent}i %{VCL_Log:sessionid}x’

And now your access logs contains the session id/cookie string. Great stuff huh?

Advertisement
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s