Trying to figure out Apache mod_rewrite and environment variables
To all the Apache experts out there...
I'm trying to configure my httpd.conf file so that I flip an environment variable or comment out a single line at the top of an httpd.conf (it's a proxy server) and "enable" redirects in various Location directives.
In the following example I have two proxy locations (app1 and app2). App1 is under maintenance and I'd like to quickly flip this one line item to force it to redirect to a maintenance page. This does not work...
If I were doing this, I would create a set of files, one for
each configuration. Then put in an include statement in the
httpd.conf that points to the current configuration.
For example, create a file named "app-normal.conf" with both
apps enabled. Create one named "app-1maint.conf" set to enable
only app2. Finally create one named "app-2maint.conf" set to
enable only app1.
Next I would create a soft link from whichever configuration
you want to enable. For example "ln -s app-normal.conf app.conf".
You would then remove the VirtualHost settings from the httpd.conf
file, and replace them with "Include app.conf". Restart the
web service and make sure it works.
After this initial setup, all you need to do to change modes
is run "ln -sf app-???.conf app.conf" and restart the webserver.
I hope my explanation makes sense. Ask if you have any questions!
Thanks for the answer, and you're response definitely makes perfect sense. The only downside is that we've got about 4 applications being serviced by this proxy (maybe a few more in the future), so all the combinations and permutations of apps being up or down could result in all sorts of different conf files.
I ended up just putting a single rewrite rule per application at the beginning of the vhost directive (before all the Location directives) so it is just a matter of uncommenting one line to put up the "maintenance" page.
Thanks for your suggestion!
Just a thought...your httpd.conf file is probably pretty large and it
might be simpler to comment a line if you put the 4 rewrite rules in
a separate file (named maintenance.conf?) and then put in a line to
include this file.
This would be especially helpful if you have multiple people who may
need to enable or disable the apps.
|All times are GMT -5. The time now is 09:26 AM.|