I retested again this morning and it is working correctly. I assumed my browser cached the request and gave me false results.<br><br>Thank you Marcus, Michal and Igor for your help.<br><br><div class="gmail_quote">2009/10/28 Igor Sysoev <span dir="ltr">&lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Wed, Oct 28, 2009 at 01:37:04AM +0000, Mathew Davies wrote:<br>

<br>
&gt; &gt;<br>
&gt; &gt; A more efficient way of doing this is :<br>
&gt; &gt;<br>
&gt;<br>
&gt; I do not see why. I am specifying &quot;return 403&quot; 3 times vs once. I was it<br>
&gt; doing it this way before and did not think it was so efficient.<br>
&gt;<br>
&gt; Here is my full config<br>
&gt;<br>
&gt; server {<br>
&gt; &gt;         listen 80;<br>
&gt; &gt;         server_name ---;<br>
&gt; &gt;         root /home/website/www/---/public/;<br>
&gt; &gt;         index index.php index.html index.htm;<br>
&gt; &gt;<br>
&gt; &gt;         # Logs<br>
&gt; &gt;         access_log /home/website/www/---/log/access.log combined;<br>
&gt; &gt;         error_log /home/website/www/---/log/error.log warn;<br>
&gt; &gt;<br>
&gt; &gt;         # Protect certain directories.<br>
&gt; &gt;         location ~* ^/(library|conf|appg) {<br>
&gt; &gt;                 return 403;<br>
&gt; &gt;         }<br>
&gt; &gt;<br>
&gt; &gt;         # Cache forum assets for as long as possible.<br>
&gt; &gt;         location ~* \.(css|js|gif|ico)$ {<br>
&gt; &gt;                 expires max;<br>
&gt; &gt;                 add_header Cache-Control private;<br>
&gt; &gt;                 break;<br>
&gt; &gt;         }<br>
&gt; &gt;<br>
&gt; &gt;         location ~* \.php$ {<br>
&gt; &gt;                 fastcgi_pass <a href="http://127.0.0.1:9000" target="_blank">127.0.0.1:9000</a>;<br>
&gt; &gt;                 fastcgi_index index.php;<br>
&gt; &gt;                 fastcgi_param SCRIPT_FILENAME<br>
&gt; &gt; $document_root$fastcgi_script_name;<br>
&gt; &gt;                 include fastcgi_params;<br>
&gt; &gt;         }<br>
&gt; &gt; }<br>
&gt; &gt;<br>
<br>
</div></div>In this configuration <a href="http://domain.com/appg/.file" target="_blank">http://domain.com/appg/.file</a> should be handled by<br>
         location ~* ^/(library|conf|appg) {<br>
Could you create debug of the request ?<br>
<div><div></div><div class="h5"><br>
&gt; Thank you for the quick response.<br>
&gt;<br>
&gt; 2009/10/28 Marcus Clyne &lt;<a href="mailto:maccaday@gmail.com">maccaday@gmail.com</a>&gt;<br>
&gt;<br>
&gt; &gt; Mathew Davies wrote:<br>
&gt; &gt;<br>
&gt; &gt;&gt; Hi.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I am having trouble with a location regular expression.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    location ~* ^/(library|conf|appg) {<br>
&gt; &gt;&gt;      return 403;<br>
&gt; &gt;&gt;    }<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;  A more efficient way of doing this is :<br>
&gt; &gt;<br>
&gt; &gt; location ^~ /library {<br>
&gt; &gt;   return   403;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt; location ^~ /conf {<br>
&gt; &gt;   return   403;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt; location ^~ /appg {<br>
&gt; &gt;   return   403;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt; since it checks the URLs using string comparison (rather than regexes) and<br>
&gt; &gt; will halt location-searching immediately if it matches one of the above<br>
&gt; &gt; locations.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;&gt; It is my understanding the following regular expression should match any<br>
&gt; &gt;&gt; uri starting with library, conf or appg. However, this is not the case.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; For instance.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    <a href="http://domain.com/appg/" target="_blank">http://domain.com/appg/</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; will match fine where as<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;    <a href="http://domain.com/appg/.file" target="_blank">http://domain.com/appg/.file</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; wont match (causing the file to be downloaded)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Am I doing something inherently wrong or is this a bug in Nginx?<br>
&gt; &gt;&gt;<br>
&gt; &gt; There&#39;s probably some other location directive in your conf that is<br>
&gt; &gt; matching <a href="http://domain.com/appg/.file" target="_blank">http://domain.com/appg/.file</a>.  If you don&#39;t want to use the more<br>
&gt; &gt; efficient, static locations above, try posting your full conf file.<br>
&gt; &gt;<br>
&gt; &gt; Marcus.<br>
&gt; &gt;<br>
&gt; &gt;<br>
<br>
</div></div><div><div></div><div class="h5">--<br>
Igor Sysoev<br>
<a href="http://sysoev.ru/en/" target="_blank">http://sysoev.ru/en/</a><br>
<br>
</div></div></blockquote></div><br>