Location regex + if + basic auth to restrict directory access

B.R. reallfqq-nginx at yahoo.fr
Sun Mar 10 19:14:55 UTC 2013


Hello,

Thanks for that... I thought the ^~ was meaning 'starting with regex'...
My bad!

I changed the symbol for some of the ones relly meaning 'regex' (~*)
 and it works! :o)

If there is no better way than sticking with
'if', then it's all good.

Thanks again, problem solved,
---
*B. R.*


On Sun, Mar 10, 2013 at 6:46 AM, Francis Daly <francis at daoine.org> wrote:

> On Sun, Mar 10, 2013 at 05:29:18AM -0400, B.R. wrote:
>
> Hi there,
>
> > The *correct* way:
> > location ^~ /documents/(\w+) {
> >     set $user $1;
> >     if ($user != $remote_user) {
> >          return 503;
> >     }
> > }
> >
> > Although the syntax is now OK and the configuration is able to be
> reloaded,
> > it doesn't seem to work at all...
>
> I haven't tested the "if" part; but in this case it's mostly likely that
> this location{} block is not being used at all.
>
> Your configuration is syntactically correct, so nginx can load it.
>
> But it is not semantically correct, as in "it does not mean what you want
> it to mean".
>
> http://nginx.org/r/location
>
> "^~" does not mean "this is a regex location"
>
>         f
> --
> Francis Daly        francis at daoine.org
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130310/cc13fa08/attachment.html>


More information about the nginx mailing list