Auth basic and fast cgi rules with request matched by location
Igor Sysoev
is at rambler-co.ru
Mon Jul 30 21:45:53 MSD 2007
On Mon, Jul 30, 2007 at 06:16:37PM +0200, tom wang wrote:
> Is there a way for a request to match more than one
> location statement?
>
> To be more clear, I have the following configuration
> file:
>
> server {
> # port to listen on. Can also be set to an IP:PORT
> listen 80;
>
> # sets the domain[s] that this vhost server
> requests for
> #server_name example.com www.example.com;
> server_name blah.jp www.blah.jp;
>
> # vhost specific access log
> access_log /var/log/nginx/blah.access_log
> main;
> error_log /var/log/nginx/blah.error_log info;
>
>
>
> root /site/www;
> index index.html index.htm index.cgi;
>
> location ~* .cgi$ {
> satisfy_any on;
> include /usr/local/nginx/conf/perl.conf;
>
> }
>
> location ~ ^/schedule {
> auth_basic "Restricted";
> auth_basic_user_file
> /site/htpasswd/schedule/passwd;
> }
>
> location ~ ^/doumei {
> auth_basic "Restricted";
> auth_basic_user_file
> /site/htpasswd/doumei/passwd;
> }
>
> error_page 500 502 503 504 /50x.html;
> location = /50x.html {
> root html;
> }
> }
>
>
> Is it possible for one request (for example
> /doumei/add.cgi) to match both the cgi directive and
> the basic authentification rules described in location
> ~ ^/doumei ?
> I have a lot of cgi script that need to be protected
> by basic authentification and I'm trying to find the
> best way to configure this.
No, request is executed in one location context.
You should define
location ~ ^/doumei/.*.cgi$ {
auth_basic "Restricted";
auth_basic_user_file /site/htpasswd/doumei/passwd;
satisfy_any on;
include /usr/local/nginx/conf/perl.conf;
}
One more hint:
- location ~ ^/schedule {
+ location /schedule {
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list