httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Eckerman <jonas_li...@frukt.org>
Subject Re: [users@httpd] httpd.config "subroutine"
Date Thu, 23 Jul 2009 14:19:51 GMT
Mike -- EMAIL IGNORED wrote:

> I have several <VirtualHost> and numerous <Directory>
> sections that have large sets of identical directives.
> If there a way to define a "subroutine" in httpd.config
> that can be called in these sections?

If you want to be able pass simple "parameters" to the "subroutine" 
sections, check out mod_macro at
<http://cri.ensmp.fr/~coelho/mod_macro/>.

I use it for vhosts the way you describe, and I really like it.

An example:
---8<---
<Macro Reverse %address %admin %server %domain %aliases>
   <VirtualHost %address>
     ServerAdmin %admin
     ServerName www.%domain
     ServerAlias %domain %aliases
     Include /usr/local/etc/apache22/filter/proxy.conf
     ProxyPass / http://%server/ keepalive=on retry=10
     ProxyPassReverse / http://%server/
     ProxyErrorOverride On
     ProxyPreserveHost On
     ProxyPassReverseCookieDomain %server www.%domain
     CacheEnable disk /
   </VirtualHost>
</Macro>

Use Reverse 10.0.7.11:80 admin@fsdb.org 10.0.7.13 edbu.org w3.edbu.org
Use Reverse 10.0.7.11:80 admin@fsdb.org 10.0.7.13 wfdb.org w3.wfdb.org
Use Reverse 10.0.7.202:80 admin@fsdb.org 10.0.6.10 fsdb.se w3.fsdb.se
---8<---

There are 28 more "Use Reverse " lines in the config, with different 
addresses and admins, and some with a whole bunch of aliases at the end. 
And then there's a bunch of vhosts using other macros as well. This way 
made it a lot easier to maintain than using includes.

Another option could be mod_perl, wich, IIRC, allows you to use perl in 
the config files.

Regards
/Jonas
-- 
Jonas Eckerman
Fruktträdet & Förbundet Sveriges Dövblinda
http://www.fsdb.org/
http://www.frukt.org/
http://whatever.frukt.org/

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message