Welcome! Log In Create A New Profile

Advanced

Re: basic-authentication and php?

May 22, 2009 01:21PM
On Fri, May 22, 2009 at 04:56:28PM +0100, Ian Hobson wrote:

> Hi all,
> I'm trying to set up basic authentication to protect an area of the
> website served by php.
>
> The critical bits of my server directive are.
>
> server (
> listen 80;
> server_name site.com www.site.com;
> root /var/www/site.com/htdocs;
> index index.php index.html index.htm;
> access_log /var/www/site.com/access.log;
>
> location ~ \.php {
> include /etc/nginx/fastcgi_params;
> fastcgi_pass 127.0.0.1:9000;
> }
>
> location ^~ /usage/ {
> auth_basic "Hello, Please login";
> auth_basic_user_file /var/www/site.com/passwords;
> }
>
> location ^~ /ppg/ {
> auth_basic "Hello, Please login";
> auth_basic_user_file /var/www/site.com/passwords;
> }
> }
>
> The directory /usage/ does NOT contain any php files and works just fine.
>
> The directory /ppg/ contains index.php - which is sent to the browser,
> not to fastcgi :(
>
> So how can I configure it. (If basic-auth cannot work, it would be ok
> to use
> allow and deny all.)
>
> I'm using nginx 0.6.35

The "/ppg/" request invokes an internel redirect to "/ppg/index.php",
which is handled in "location ^~ /ppg/", because regex testing is disabled
by "^~". You should either remove "^~":

- location ^~ /ppg/ {
+ location /ppg/ {

or add additional

location = /ppg/index.php {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
auth_basic "Hello, Please login";
auth_basic_user_file /var/www/site.com/passwords;
}


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

basic-authentication and php?

Ian Hobson May 22, 2009 11:56AM

Re: basic-authentication and php?

Jim Ohlstein May 22, 2009 12:30PM

Re: basic-authentication and php?

Ian Hobson May 22, 2009 01:12PM

Re: basic-authentication and php?

mike May 22, 2009 01:27PM

Re: basic-authentication and php?

Jim Ohlstein May 22, 2009 01:31PM

Re: basic-authentication and php?

mike May 22, 2009 01:36PM

Re: basic-authentication and php?

Jim Ohlstein May 22, 2009 01:45PM

Re: basic-authentication and php?

Igor Sysoev May 22, 2009 01:42PM

Re: basic-authentication and php?

Jim Ohlstein May 22, 2009 01:54PM

Re: basic-authentication and php?

Igor Sysoev May 22, 2009 01:21PM

Re: basic-authentication and php?

Ian Hobson May 22, 2009 05:52PM

Re: basic-authentication and php?

Igor Sysoev May 23, 2009 01:31AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 138
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready