:Author: Aivars Kalvans aivars.kalvans@gmail.com :Date: 2013-01-18 :Version: 0.1 :Manual section: 3
import rewrite;
Varnish vmod hack demonstrating how to rewrite HTML content. It's not production-ready - I'm still learning and looking for the best way how to do it.
Rewrite is performed only once and the rewritten document is stored in cache.
Buy me a drink!
__
Prototype ::
rewrite_re(STRING SEARCH_REGEX, STRING REPLACEMENT)
Return value VOID Description Rewrites all parts of document matching SEARCH_REGEX with REPLACEMENT
Usage::
./configure VARNISHSRC=DIR [VMODDIR=DIR]
VARNISHSRC
is the directory of the Varnish source tree for which to
compile your vmod. Both the VARNISHSRC
and VARNISHSRC/include
will be added to the include search paths for your module.
Optionally you can also set the vmod install directory by adding
VMODDIR=DIR
(defaults to the pkg-config discovered directory from your
Varnish installation).
Make targets:
VMODDIR
In your VCL you could then use this vmod along the following lines::
import rewrite;
sub vcl_deliver {
rewrite.rewrite_re("https://www.paypal.com/cgi-bin/webscr\?cmd=_donations&business=[^&]+&", "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=FUPUJSJ9KCPAL&");
}
(No I'm not that evil)
See COPYING for details.