Welcome! Log In Create A New Profile

Advanced

Re: Switches in configuration files?

June 18, 2009 12:35PM
On Thu, Jun 18, 2009 at 3:05 AM, Rt Ibmer<rtibmx@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
Subject Author Posted

Switches in configuration files?

Rt Ibmer June 17, 2009 04:05PM

Re: Switches in configuration files?

Rt Ibmer June 18, 2009 12:22PM

Re: Switches in configuration files?

edogawaconan June 18, 2009 12:35PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 128
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready