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!