Backend selection based on integer value in request?

Paul A. Procacci pprocacci at datapipe.com
Wed Oct 10 03:43:21 CEST 2012


On Tue, Oct 09, 2012 at 07:58:40PM -0500, Paul A. Procacci wrote:
> You probably want something like the following (untested):
>
> ######################################
> if(req.url ~ "/\d+\.jpg$"){
>   set req.http.X-Image-Int = req.url;
>   regsub( req.http.X-Image-Int, "/(\d+)\.jpg$", "\1");
>   if(std.integer(req.http.X-Image-Int, 0) > 10) {
>     set req.backend = foo;
>   }
>   elseif(std.integer(req.http.X-Image-Int, 0) > 5) {
>     set req.backend = foo2;
>   }
>   remove req.http.X-Image-Int;
> }
> ######################################
>
> ~Paul

Apologies for the posting to myself.  My regex is poor.

>   regsub( req.http.X-Image-Int, "/(\d+)\.jpg$", "\1");

Probably should be:

regsub( req.http.X-Image-Int, ".*/(\d+)\.jpg$", "\1");

~Paul

________________________________

This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.



More information about the varnish-misc mailing list