Welcome! Log In Create A New Profile

Advanced

Re: Can auth_basic restrict files in certain folder?

Rob Schultz
March 28, 2010 11:18PM
Hi Gavin,

> I have some problem with my nginx
> I just could not restrict files in certain floder, as follows, i put the settings to nginx.conf
>
> location ~ ^/restrict/
> {
> auth_basic "STATISTIC";
> auth_basic_user_file /usr/local/nginx/conf/pwfornginx
> }
>
>
> the folder /restrict/ is restricted perfect, however, files in the folder can still be accessed,
> /restrict/somefile.php
>
> What's the matter? any ideas?

The problem is you somewhat have to rethink how NginX process the request. read here for more details http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration but to sum it up you probably have a something like
location ~ .*\.php${
}
in your config which actually handles the /restrict/somefile.php instead of
location ~ ^/restrict/ { }
there is two ways to remidy this. you can do something like

location ~ ^/restrict/.*\.php$ {
#rest of auth config
}

or you can do sub-locations *note* this is the only instance that i have read where it is safe to do nested locations. YMMV

location ~ ^/restrict/
{
auth_basic "STATISTIC";
auth_basic_user_file /usr/local/nginx/conf/pwfornginx
location ~ .*\.php$ {
#include your php config for processing ie proxy_pass or fastcgi_pass
}
}

v/r,
Rob
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Can auth_basic restrict files in certain folder?

WisdomFusion March 28, 2010 10:32PM

Re: Can auth_basic restrict files in certain folder?

Rob Schultz March 28, 2010 11:18PM

Re: Can auth_basic restrict files in certain folder?

WisdomFusion March 29, 2010 03:08AM

Re: Can auth_basic restrict files in certain folder?

WisdomFusion March 29, 2010 01:40AM

Re: Can auth_basic restrict files in certain folder?

WisdomFusion March 29, 2010 01:42AM



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