Welcome! Log In Create A New Profile

Advanced

Re: location and file extension regex

Musta Fa
December 03, 2016 09:30AM
while i request files
http://domain.com/config.xml
or
http://domain.com/include/config.xml
both files downloaded, which is not good,

simple ~* /\.(tpl|xml)$ {return 404;}
works perfect but blocks files everywhere.



On Sat, Dec 3, 2016 at 2:07 PM, Francis Daly <francis@daoine.org> wrote:

> On Sat, Dec 03, 2016 at 12:19:44PM +0000, Musta Fa wrote:
>
> Hi there,
>
> > im trying to create some regex just to match before second slash and
> only.
> > and allow all subfolders:
> >
> > location ~ ^/([^/])+\.(tpl|xml)$ { return 404; }
> >
> > these files are located in root folder, and i dont want them to be
> > downloaded,
> > but other files in subfolder are downloadable.
> >
> > not sure why it not working?
>
> Why do you think it is not working?
>
> What request do you make that you want to match this location, but it
> does not?
>
> What request do you make that you want not to match this location,
> but it does?
>
> Test:
>
> ==
> server {
> listen 8888;
> location ~ ^/([^/])+\.(tpl|xml)$ { return 200 "Did match: $uri\n"; }
> location / { return 200 "Did not match: $uri\n"; }
> }
> ==
>
> $ curl http://127.0.0.1:8888/abc.xml
> Did match: /abc.xml
> $ curl http://127.0.0.1:8888/abc/def.xml
> Did not match: /abc/def.xml
> $ curl http://127.0.0.1:8888/abc.txt
> Did not match: /abc.txt
>
> f
> --
> Francis Daly francis@daoine.org
>
> _______________________________________________
> 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
Subject Author Posted

location and file extension regex

Musta Fa December 03, 2016 07:22AM

Re: location and file extension regex

Francis Daly December 03, 2016 09:08AM

Re: location and file extension regex

Musta Fa December 03, 2016 09:30AM

Re: location and file extension regex

Francis Daly December 03, 2016 09:56AM

Re: location and file extension regex

Musta Fa December 03, 2016 10:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 140
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready