Welcome! Log In Create A New Profile

Advanced

location ~* .(a|b|c)$ {} caused an error

Posted by Sophie Loewenthal 
Sophie Loewenthal
location ~* .(a|b|c)$ {} caused an error
December 04, 2017 06:00PM
Hi,

When I put this location block for case insensitive matching into the vhost produced an error.

nginx: [emerg] location "/" is outside location ".(jpg|jpeg|png|gif|ico|css|js)$" in /etc/nginx/sites-enabled/example.conf:13

My vhost has this:

server {

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 65d;

location / {
allow all;
limit_req zone=app burst=5;
limit_rate 64k;
}

}

Did I misread the http://nginx.org/en/docs/http/ngx_http_core_module.html#location doxs?

Quote "A location can either be defined by a prefix string, or by a regular expression. Regular expressions are specified with the preceding “~*” modifier (for case-insensitive matching),"


Thanks, Sophie.




_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Ian Hobson
Re: location ~* .(a|b|c)$ {} caused an error
December 04, 2017 07:00PM
Hi Sophie,

On 04/12/2017 16:49, Sophie Loewenthal wrote:
> Hi,
>
> When I put this location block for case insensitive matching into the vhost produced an error.
>
> nginx: [emerg] location "/" is outside location ".(jpg|jpeg|png|gif|ico|css|js)$" in /etc/nginx/sites-enabled/example.conf:13
>
> My vhost has this:
>
> server {
> …
> location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
> expires 65d;
You need to close the first location here, before opening the second one.
>
> location / {
> allow all;
> limit_req zone=app burst=5;
> limit_rate 64k;
> }
> …
> }
>
> Did I misread the http://nginx.org/en/docs/http/ngx_http_core_module.html#location doxs?

Quite possibly - matching is rather complex.

I have been caught by the order of matching which is NOT the order of
declaration. I need to check it every time I create a configuration.

Regards

Ian
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sophie Loewenthal
Re: location ~* .(a|b|c)$ {} caused an error
December 04, 2017 07:20PM
Oh. the closing }

It’s been a long day <:-I


> On 4 Dec 2017, at 18:57, Ian Hobson <[email protected]> wrote:
>
> Hi Sophie,
>
> On 04/12/2017 16:49, Sophie Loewenthal wrote:
>> Hi,
>> When I put this location block for case insensitive matching into the vhost produced an error.
>> nginx: [emerg] location "/" is outside location ".(jpg|jpeg|png|gif|ico|css|js)$" in /etc/nginx/sites-enabled/example.conf:13
>> My vhost has this:
>> server {
>> …
>> location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
>> expires 65d;
> You need to close the first location here, before opening the second one.
>> location / {
>> allow all;
>> limit_req zone=app burst=5;
>> limit_rate 64k;
>> }
>> …
>> }
>> Did I misread the http://nginx.org/en/docs/http/ngx_http_core_module.html#location doxs?
>
> Quite possibly - matching is rather complex.
>
> I have been caught by the order of matching which is NOT the order of declaration. I need to check it every time I create a configuration.
>
> Regards
>
> Ian
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login