Maintenance mode for all but my ip

Jonathan Matthews contact at jpluscplusm.com
Sat Dec 7 21:14:25 UTC 2013


On 7 December 2013 15:19, B.R. <reallfqq-nginx at yahoo.fr> wrote:
> Hello,
>
>
> On Sat, Dec 7, 2013 at 4:10 PM, Jonathan Matthews <contact at jpluscplusm.com>
> wrote:
>>
>> >     rewrite ^.*$ $target #Redirecting all traffic according to
>> > map-assigned
>>
>> I don't particularly like ^^^ this. It seems like a level of
>> indirection too far ;-)
>
> To me, your solution looks double evil:
> 1°) Using an unneeded 'if' directive

Using "if" is absolutely fine if all you're doing is issuing a return
directly from it. It's only when you try to do things /after/ an "if"
successfully matches that it's considered evil ...

> 2°) Needs modifying each and every location block.

I didn't really pay attention to the scoping of the return. Moving the
return to the most appropriate place in the config shouldn't be too
tricky for the OP to figure out ...

> I was trying to think about something more scalable, self-contained and
> generic. ;o)

What I suggested would work, AFAICT, with a single map, and a
per-server{} "if($not_me){return 503;}". That's hardly onerous, I'd
say ...

YMMV,
Jonathan



More information about the nginx mailing list