<div dir="ltr">
<p class=""><span style>Hello Everyone,</span></p>
<p class=""><span style></span></p>
<p class=""><span style>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 class=""><span style></span></p>
<p class=""><span style>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 style> </span>c MATCH
passem </span><span style><span style>7x.xxx.xxx.xxx</span>”. However, even though it is matching the acl, the cache is still not being bypassed.</span></p>
<p class=""><span style></span></p>
<p class=""><span style>I have a feeling it has to do with the “</span><span style>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 class=""><span style></span></p>
<p class=""><span style>I would really greatly
appreciate the help getting this to work. Many thanks.</span><span style></span></p>
<p class="" style><span style><span style><br></span></span></p><p class="" style><span style><span style> </span>C{</span></p>
<p class="" style><span style><span style>
</span>#include <netinet/in.h></span></p>
<p class="" style><span style><span style>
</span>#include <string.h></span></p>
<p class="" style><span style><span style>
</span>#include <sys/socket.h></span></p>
<p class="" style><span style><span style>
</span>#include <arpa/inet.h></span></p>
<p class="" style><span style><span style> </span>}C</span></p>
<p class="" style><span style><span style> </span>acl
passem { "7x.xxx.xxx.xxx"; }</span></p>
<p class="" style><span style><span style> </span>sub
vcl_recv {</span></p>
<p class="" style><span style><span style> </span>C{</span></p>
<p class="" style><span style><span style>
</span>struct sockaddr_storage *client_ip_ss = VRT_r_client_ip(sp);</span></p>
<p class="" style><span style><span style>
</span>struct sockaddr_in *client_ip_si = (struct sockaddr_in *) client_ip_ss;</span></p>
<p class="" style><span style><span style> </span><span style> </span>struct in_addr *client_ip_ia =
&(client_ip_si->sin_addr);</span></p>
<p class="" style><span style><span style> </span>char
*xff_ip = VRT_GetHdr(sp, HDR_REQ, "\020X-Forwarded-For:");</span></p>
<p class="" style><span style> </span></p><p class="" style><span style><span style> </span>if
(xff_ip != NULL) {</span></p>
<p class="" style><span style><span style>
</span>inet_pton(AF_INET, xff_ip, client_ip_ia);</span></p>
<p class="" style><span style><span style> </span>}</span></p>
<p class="" style><span style><span style> </span>}C</span></p>
<p class="" style><span style><span style> </span>if
(!(client.ip ~ passem)) {</span></p>
<p class="" style><span style><span style> </span>return
(pass);</span></p>
<p class="" style><span style><span style>
</span>}</span></p>
<p class="" style><span style><span style> </span>}</span></p>
<p class=""><span style> </span></p>
</div>