<br><br><div class="gmail_quote">On Fri, Feb 10, 2012 at 6:08 PM, Max <span dir="ltr"><<a href="mailto:nginxyz@mail.ru">nginxyz@mail.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
10 ÆÅ×ÒÁÌÑ 2012, 23:40 ÏÔ Guilherme <<a href="mailto:guilherme.e@gmail.com">guilherme.e@gmail.com</a>>:<br>
<div class="im">> This would fix the problem, but I don't know the directories that has a<br>
> .htaccess file with allow/deny.<br>
><br>
> Example:<br>
><br>
> Scenario: nginx (cache/proxy) + back-end apache<br>
><br>
> root@srv1 [~]# ls -a /home/domain/public_html/restrictedimages/<br>
> ./ š../ š.htaccess šimage.jpg<br>
> root@srv1 [~]# cat /home/domain/public_html/restrictedimages/.htaccess<br>
> allow from x.x.x.x<br>
> deny from all<br>
><br>
> In the first access (source IP: x.x.x.x) to<br>
> <a href="http://domain.com/restrictedimages/image.jpg" target="_blank">http://domain.com/restrictedimages/image.jpg</a>, nginx proxy request to apache<br>
> and cache response. The problem comes in other request from other šIP<br>
> address different from x.x.x.x. Nginx deliver the objects from cache, even<br>
> if the ip address is not authorized, because nginx doesn't understand<br>
> .htaccess.<br>
><br>
> I would like to bypass cache in this cases, maybe using proxy_cache_bypass,<br>
> but I don't know how. Any idea?<br>
<br>
</div>You could use this:<br>
<br>
proxy_cache_key $scheme$remote_addr$host$$server_port$request_uri;<br>
<br>
This would make originating IP addresses ($remote_addr) part of<br>
the cache key, so different clients would get the correct responses<br>
from the cache just as if they were accessing the backend directly,<br>
there's no need to bypass the cache at all.<br>
<span class="HOEnZb"><font color="#888888"><br>
Max<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a></div></div></blockquote></div><br>Max, good idea, but in the other requests, that I want to cache
responses, the cache size will grow too fast, because the same object
will be cached a lot of times, cause the ip adress is in the cache key (one cache entry per IP).<br><br><br>