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