if (req.restarts == 0) VCL Error

Per Buer perbu at varnish-software.com
Wed May 7 08:52:23 CEST 2014


Hi Tim.


On Wed, May 7, 2014 at 4:27 AM, Tim Dunphy <bluethundr at gmail.com> wrote:

> Hey All,
>
>  I'm trying to write a VCL subroutine. The purpose of the section I am
> having a problem with is to set some headers when it encounters a restart
> condition. Here's the code.
>
> sub vcl_recv {
>     if (req.restarts == 0) {
>       if (req.http.x-forwarded-for) {
>            set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", "
> + client.ip;
>        } else {
>        set req.http.X-Forwarded-For = client.ip;  }
>     }
>
>     if (req.request != "GET"&&req.request != "HEAD") {
>       return (pass);
>     }
>
>     set req.backend = www;
> }
>

FWIW, I took the above code, put it in a file, along with a backend named
www and the code compiled and loaded just fine.


-- 
 <http://www.varnish-software.com/> *Per Buer*
CTO | Varnish Software
Phone: +47 958 39 117 | Skype: per.buer
We Make Websites Fly!

Winner of the Red Herring Top 100 Global Award 2013
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140507/119d4236/attachment.html>


More information about the varnish-misc mailing list