12 messages in ru.sysoev.nginxRe: basic-authentication and php?
FromSent OnAttachments
Ian HobsonMay 22, 2009 8:56 am 
Jim OhlsteinMay 22, 2009 9:29 am 
Ian HobsonMay 22, 2009 10:12 am 
Igor SysoevMay 22, 2009 10:21 am 
Michael ShadleMay 22, 2009 10:26 am 
Jim OhlsteinMay 22, 2009 10:30 am 
Michael ShadleMay 22, 2009 10:36 am 
Igor SysoevMay 22, 2009 10:42 am 
Jim OhlsteinMay 22, 2009 10:45 am 
Jim OhlsteinMay 22, 2009 10:54 am 
Ian HobsonMay 22, 2009 2:51 pm 
Igor SysoevMay 22, 2009 10:30 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: basic-authentication and php?Actions...
From:Michael Shadle (mike@gmail.com)
Date:May 22, 2009 10:26:45 am
List:ru.sysoev.nginx

location /foo { auth_basic .. auth_bsic_user_file ... location ~ \.php { } }

is how i've done it. you have to nest the php again inside of it, but otherwise treat it no differently.

igor - you should make some sort of syntax for a globally effective location or something - one that takes effect *always* within a server block, at the end.

this would help for parsing PHP *always* if there is a .php file, *always* include the expires headers, etc. right now, i've had to wind up nesting those type of things inside of blocks where auth is required for example (like above) - that would make location blocks to me a lot easier to deal with.

essentially it would deal with all the location blocks and then apply these "global" ones -after- it's done with the others...

On Fri, May 22, 2009 at 10:12 AM, Ian Hobson <ia@ianhobson.co.uk> wrote:

Jim Ohlstein wrote:

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;  }

I would try

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

Hi Jim,

I tried that, and got no style sheet, so I presumed that static files were not being served. However, you are right. It works.

However, the error long in FireFox is telling me....

Error: The stylesheet http://www.site.com/ppg/css/style.css was not loaded because its MIME type, "text/html", is not "text/css". Source File: http://www.site.com/ppg/ Line: 0

I've checked /etc/nginx/mine-types, and it claims type text/css  for css files, and the default-type is application/octet-stream.

So now I'm really confused.

p.s IE 6.0 is not so fussy. It simply leaves out some of the images :(