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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Sophie Loewenthal
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
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Ian
Reply | Threaded
Open this post in threaded view
|

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

Ian
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
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

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

Sophie Loewenthal
Oh. the closing }

It’s been a long day     <:-I


On 4 Dec 2017, at 18:57, Ian Hobson <[hidden email]> 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
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx