Maintenance mode for all but my ip

Ian Evans ianevans at digitalhit.com
Sat Dec 7 17:31:35 UTC 2013


On 2013-12-07 09:58, B.R. wrote:
> I am new to the use of maps, but I suppose it would fit perfectly,
> using core variables such as the binary IP address:
> Maybe something like:
>
> server {
>     error_page 503 /503.html # Configuring error page
>
>     map $binary_remote_addr $target { # Configuring white-listed IP
> addresses
>        
> default                                                   
> KO
>          your_whitelisted_binary_IP_address_value OK
>     }
>
>     rewrite ^.*$ $target #Redirecting all traffic according to
> map-assigned value
>
>     location @OK { # Named location to do nothing, i.e. serve
> content as usual
>      }
>
>     location @KO { # Named location to trap maintenance traffic,
> spawning a HTTP 503 error
>         return 503;
>     }
> }
>
> Untested, thus unsure, but Id seek something looking like this.

Thanks. I'll give this a spin. Is there anyway to still trigger the 
mapping based on the existence of a maintenance.whatever file? Just 
thinking of the ease of quickly touch'ing the maintenance file to 
trigger the mapping as opposed to fiddling with the conf and reloading 
each time you want to do some quick testing.



More information about the nginx mailing list