lowercasing request - varnish 4

Brice Burgess nesta at iceburg.net
Tue Sep 30 10:42:50 CEST 2014


On 09/30/2014 01:40 AM, Andreas Plesner Jacobsen wrote:
> On Mon, Sep 29, 2014 at 11:46:48PM -0500, Brice Burgess wrote:
>
>> I would like to lowercase both the host and url during my
>> normalization routines in vcl_recv. Stackoverflow has an example
>> using embedded C;
> [...]
>
>> Is this the recommended approach
> No. Use the tolower method in the std vmod. man vmod_std
>

Thanks Andreas. Much preferred!  I'm now doing something like this;

normalization.vcl
====

vcl 4.0;

import std;

sub vcl_recv {

   # normalize Host header
   set req.http.Host = std.tolower(regsub(req.http.Host, ":[0-9]+", ""));


   # URL MANIPULATIONS
   ###################

   # lowercase request URL
   set req.url = std.tolower(req.url);

   ....

}

Appears to be working well!

~ Brice





More information about the varnish-misc mailing list