<div dir="ltr"><div>How do the logs describe the request? Hit/Miss/Pass? How are you sure that the content is being served out of the cache?</div><div><br></div><div>Also, you might want to consider using <a href="https://github.com/lkarsten/libvmod-ipcast">ipcast</a> to set the client.ip from the x-forwarded-for headers. It's a lot cleaner than using the inline C. We use it to do what you're describing.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 12, 2013 at 12:12 PM, iPhrankie <span dir="ltr"><<a href="mailto:iphrankie@gmail.com" target="_blank">iphrankie@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">

<p><span>Hello Everyone,</span></p>

<p><span></span></p>

<p><span>We're using Varnish 3.0.3 behind a load balancer.
We would like to bypass the Varnish cache for a particular visitor IP address. </span></p>

<p><span></span></p>

<p><span>After doing research, I found the following solution. We’re using
the following in order for the acl to match the
"http.x-forwarded-for" string. This code is working and within
varnishlog I see “6 VCL_acl<span> </span>c MATCH
passem </span><span><span>7x.xxx.xxx.xxx</span>”. However, even though it is matching the acl, the cache is still not being bypassed.</span></p>

<p><span></span></p>

<p><span>I have a feeling it has to do with the “</span><span>sub vcl_recv” or the “return (pass)”. I also
tried using “set req.hash_always_miss = true;” instead of “return (pass)”, but
this also didn’t work.</span></p>

<p><span></span></p>

<p><span>I would really greatly
appreciate the help getting this to work. Many thanks.</span><span></span></p>

<p><span><span><br></span></span></p><p><span><span>    </span>C{</span></p>

<p><span><span>   
</span>#include <netinet/in.h></span></p>

<p><span><span>   
</span>#include <string.h></span></p>

<p><span><span>   
</span>#include <sys/socket.h></span></p>

<p><span><span>   
</span>#include <arpa/inet.h></span></p>

<p><span><span>    </span>}C</span></p>

<p><span><span>    </span>acl
passem { "7x.xxx.xxx.xxx"; }</span></p>

<p><span><span>    </span>sub
vcl_recv {</span></p>

<p><span><span>    </span>C{</span></p>

<p><span><span>   
</span>struct sockaddr_storage *client_ip_ss = VRT_r_client_ip(sp);</span></p>

<p><span><span>   
</span>struct sockaddr_in *client_ip_si = (struct sockaddr_in *) client_ip_ss;</span></p>

<p><span><span>  </span><span>  </span>struct in_addr *client_ip_ia =
&(client_ip_si->sin_addr);</span></p>

<p><span><span>    </span>char
*xff_ip = VRT_GetHdr(sp, HDR_REQ, "\020X-Forwarded-For:");</span></p>

<p><span> </span></p><p><span><span>    </span>if
(xff_ip != NULL) {</span></p>

<p><span><span>   
</span>inet_pton(AF_INET, xff_ip, client_ip_ia);</span></p>

<p><span><span>    </span>}</span></p>

<p><span><span>    </span>}C</span></p>

<p><span><span>    </span>if
(!(client.ip ~ passem)) {</span></p>

<p><span><span>    </span>return
(pass);</span></p>

<p><span><span>           
</span>}</span></p>

<p><span><span>    </span>}</span></p>

<p><span> </span></p>

</div>
<br>_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>

<div dir="ltr">Stephen Wood<div><a href="http://www.heystephenwood.com" target="_blank">www.heystephenwood.com</a></div></div>
</div>