Switches in configuration files?

Edho P Arief edhoprima at gmail.com
Thu Jun 18 20:35:08 MSD 2009


On Thu, Jun 18, 2009 at 3:05 AM, Rt Ibmer<rtibmx at yahoo.com> wrote:
>
> Is there a way to create a variable in the config file that I can set to true or false (or 1 or 2, etc) and then make my location blocks do an IF operation based on that var to take different actions in the block.
>
> For instance this is what I currently have:
>
>  location ~* /maindir/area1 {
>        error_page   500 502 503 504  /service-is-down.html;
>
>        access_log  /main.log main;
>        proxy_pass  http://my_farm;
>
>        # To temporarily take service offline, comment out the 2 lines above, and remove the comments from below.
>        # The incoming requests will then be logged for manual later handling.
>        # access_log  /deferred.log main;
>        # empty_gif;
>        # expires -1d;
>    }
>
> And instead I'd rather have something like this:
>
>  location ~* /maindir/area1 {
>        error_page   500 502 503 504  /service-is-down.html;
>
>     if(inMaintenanceMode == true) {
>        access_log  /main.log main;
>        proxy_pass  http://my_farm;
>     }
>     else
>     {
>        access_log  /deferred.log main;
>        empty_gif;
>        expires -1d;
>     }
>    }
>

maybe something like this

 location ~* /maindir/area1 {
       error_page   500 502 503 504  /service-is-down.html;
       try_files /maintenance.html @myfarm
}

location @myfarm {
       access_log  /main.log main;
       proxy_pass  http://my_farm;
}

location /maintenance.html {
       access_log  /deferred.log main;
       expires -1d;
}

create/touch /maintenance.html to switch offline

> Can this sort of thing be done and if so can someone please demonstrate with a tiny snippet? Thanks!
>
>
>
>
>



-- 
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org





More information about the nginx mailing list