httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Eckerman <>
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

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

An example:
<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 /

Use Reverse
Use Reverse
Use Reverse

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.

Jonas Eckerman
Fruktträdet & Förbundet Sveriges Dövblinda

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message