Welcome! Log In Create A New Profile

Advanced

Re: Location regex

Mathew Davies
October 28, 2009 10:56AM
I retested again this morning and it is working correctly. I assumed my
browser cached the request and gave me false results.

Thank you Marcus, Michal and Igor for your help.

2009/10/28 Igor Sysoev <is@rambler-co.ru>

> On Wed, Oct 28, 2009 at 01:37:04AM +0000, 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.
> >
> > 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;
> > > fastcgi_index index.php;
> > > fastcgi_param SCRIPT_FILENAME
> > > $document_root$fastcgi_script_name;
> > > include fastcgi_params;
> > > }
> > > }
> > >
>
> In this configuration http://domain.com/appg/.file should be handled by
> location ~* ^/(library|conf|appg) {
> Could you create debug of the request ?
>
> > Thank you for the quick response.
> >
> > 2009/10/28 Marcus Clyne <maccaday@gmail.com>
> >
> > > Mathew Davies wrote:
> > >
> > >> Hi.
> > >>
> > >> I am having trouble with a location regular expression.
> > >>
> > >> location ~* ^/(library|conf|appg) {
> > >> return 403;
> > >> }
> > >>
> > >> A more efficient way of doing this is :
> > >
> > > location ^~ /library {
> > > return 403;
> > > }
> > >
> > > location ^~ /conf {
> > > return 403;
> > > }
> > >
> > > location ^~ /appg {
> > > return 403;
> > > }
> > >
> > > 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.
> > >
> > >
> > >
> > >
> > >> It is my understanding the following regular expression should match
> any
> > >> uri starting with library, conf or appg. However, this is not the
> case.
> > >>
> > >> For instance.
> > >>
> > >> http://domain.com/appg/
> > >>
> > >>
> > >> will match fine where as
> > >>
> > >> http://domain.com/appg/.file
> > >>
> > >>
> > >> wont match (causing the file to be downloaded)
> > >>
> > >> Am I doing something inherently wrong or is this a bug in Nginx?
> > >>
> > > There's probably some other location directive in your conf that is
> > > matching http://domain.com/appg/.file. If you don't want to use the
> more
> > > efficient, static locations above, try posting your full conf file.
> > >
> > > Marcus.
> > >
> > >
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>
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: 255
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