Welcome! Log In Create A New Profile

Advanced

basic auth w/php-fpm...what I am doing wrong?

Posted by raindog308 
basic auth w/php-fpm...what I am doing wrong?
April 10, 2011 01:08PM
have a site with a structure like this:

www.example.org - if you got to / you get a wordpress CMS
www.example.org/wiki - a mediawiki
www.example.org/project - projectpier
etc.

I'd like www.example.org/wiki and www.example.org/project to require basic auth. I know how to use basic auth, but the problem is that nginx will match the most specific rule.

So I have this rule to match .php anywhere:

location ~ \.php$ {

Another rule for /wiki sets the basic auth:

location /wiki {

what happens is that for the .php files, the first rule is matched and they're shown regardless of the basic auth rule in the second rule. Other non .php files are protected. Obviously, this isn't what I want.

This is quite different than apache's .htaccess, where I'd just drop a .htaccess in /wiki and it worked fine.

I tried

location ~ /wiki.*\.php$ {

But that didn't appear to work either.

I tried

location ~ /wiki.*\.php$ {

but that didn't seem to work either...in fact, the message is

2011/04/10 10:06:51 [error] 19470#0: *1 open() "/usr/local/nginx/html/wiki" failed (2: No such file or directory), client: x.x.x.x, server: example.org, request: "GET /wiki HTTP/1.1", host: "www.example.org"

That is strange since /usr/local/nginx doesn't exist and that string doesn't appear anywhere in /etc/php5 or /etc/nginx.

So...can I accomplish this in nginx? Or do I need to do something like setup wiki.example.org and project.example.org DNS aliases/virtual servers and manage it that way? That seems a long way around for what seems so simple...there must be something obviously simple.

Thanks in advance!
Re: basic auth w/php-fpm...what I am doing wrong?
April 14, 2011 05:09AM
/usr/local/nginx is the default document root set by nginx ( via ./configure )
you need to set the document root using the root directive.

Here you can read more about it
http://wiki.nginx.org/HttpCoreModule#root



Edited 1 time(s). Last edit at 04/14/2011 05:10AM by mfeldheim.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 144
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