Welcome! Log In Create A New Profile

Advanced

Re: Location regex

Marcus Clyne
October 27, 2009 11:02PM
Mathew Davies wrote:
>
> A more efficient way of doing this is :
>
>
> I do not see why. I am specifying "return 403" 3 times vs once. I was
> it doing it this way before and did not think it was so efficient.
When referring to 'efficient' I'm talking about the speed at which the
statements are processed by Nginx. Sorry if that wasn't clear.
>
> Here is my full config
>
> server {
> listen 80;
> server_name ---;
> root /home/website/www/---/public/;
> index index.php index.html index.htm;
>
> # Logs
> access_log /home/website/www/---/log/access.log combined;
> error_log /home/website/www/---/log/error.log warn;
>
> # Protect certain directories.
> location ~* ^/(library|conf|appg) {
> return 403;
> }
>
> # Cache forum assets for as long as possible.
> location ~* \.(css|js|gif|ico)$ {
> expires max;
> add_header Cache-Control private;
> break;
> }
>
> location ~* \.php$ {
> fastcgi_pass 127.0.0.1:9000 http://127.0.0.1:9000;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> include fastcgi_params;
> }
> }
>
What's the URL you're having problems with and which location is it
matching too? Since all the locations are regexes, I would have thought
that they would be processed in order - though I'm not sure if they are
somehow re-ordered according to certain matching priorities (though I
doubt it).


Using

location ^~ /library {
return 403;
}

location ^~ /conf {
return 403;
}

location ^~ /appg {
return 403;
}

will guarantee that they are processed (and matching halted) before
processing any regexes though, which is probably a good reason to put
them in that format anyway (if you change the ordering of your regexes,
then this might change the location they are matched to).

Marcus.
Subject Author Posted

Location regex

Mathew Davies October 27, 2009 08:30PM

Re: Location regex

Marcus Clyne October 27, 2009 09:00PM

Re: Location regex

Mathew Davies October 27, 2009 09:44PM

Re: Location regex

Marcus Clyne October 27, 2009 11:02PM

Re: Location regex

Michal Kowalski October 27, 2009 11:02PM

Re: Location regex

Igor Sysoev October 28, 2009 03:34AM

Re: Location regex

Mathew Davies October 28, 2009 10:56AM

Re: location regex

Igor Sysoev November 01, 2016 10:06AM

Re: location regex

olat November 01, 2016 06:49PM

Re: location regex

Igor Sysoev November 02, 2016 07:30AM

Re: location regex

Francis Daly November 03, 2016 02:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 79
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready