Switches in configuration files?
Rt Ibmer
rtibmx at yahoo.com
Thu Jun 18 00:05:07 MSD 2009
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;
}
}
Can this sort of thing be done and if so can someone please demonstrate with a tiny snippet? Thanks!
More information about the nginx
mailing list