<div dir="ltr">Hey All,<div><br></div><div> 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.</div>
<div><br></div><div><div>sub vcl_recv {</div><div> if (req.restarts == 0) {</div><div> if (req.http.x-forwarded-for) {</div><div> set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;</div>
<div> } else {</div><div> set req.http.X-Forwarded-For = client.ip; }</div><div> }</div><div><br></div><div> if (req.request != "GET"&&req.request != "HEAD") {</div><div> return (pass);</div>
<div> }</div><div><br></div><div> set req.backend = www;</div><div>}</div><div><br></div><div>And here is the error I'm getting:</div><div><br></div><div><div>[root@varnish1 varnish]# varnishd -C -f default.vcl</div>
<div>Message from VCC-compiler:</div><div>Syntax error at</div><div>('input' Line 39 Pos 30)</div><div> if (req.restarts == 0) {</div><div>-----------------------------#-</div><div><br></div><div>Running VCC-compiler failed, exit 1</div>
<div><br></div><div>VCL compilation failed</div></div><div><br></div><div>I'm not entirely sure why, but it looks as if the phrase: </div><div><br></div><div>if (req.restarts == 0)<br></div><div><br></div><div>Is causing it to error out.</div>
<div><br></div><div>If I remove that one condition, the VCL does work! So if we're left with just:</div><div><br></div><div><div>sub vcl_recv {</div><div><br></div><div> if (req.request != "GET"&&req.request != "HEAD") {</div>
<div> return (pass);</div><div> }</div><div><br></div><div> set req.backend = www;</div></div><div><br></div><div>In the sub vcl looks like we're ok!</div><div><br></div><div><div>[root@varnish1 varnish]# service varnish reload</div>
<div>Loading vcl from /etc/varnish/default.vcl</div><div>Current running config name is reload_2014-05-06T22:13:17</div><div>Using new config name reload_2014-05-06T22:26:27</div><div>VCL compiled.</div><div><br></div><div>
available 0 boot</div><div>available 6 reload_2014-05-06T22:13:17</div><div>active 0 reload_2014-05-06T22:26:27</div><div><br></div><div>Done</div></div><div><br></div><div>I would definitely appreciate any advice you may have as to why the above condition is not working.</div>
<div><br></div><div>Thanks,</div><div>Tim</div><div><br></div><div><br></div><div><br></div>-- <br>GPG me!!<br><br>gpg --keyserver <a href="http://pool.sks-keyservers.net" target="_blank">pool.sks-keyservers.net</a> --recv-keys F186197B<br>
<br>
</div></div>