Re: httpd.config "subroutine"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx 10.0.7.13 edbu.org w3.edbu.org
Use Reverse 10.0.7.11:80 admin@xxxxxxxx 10.0.7.13 wfdb.org w3.wfdb.org
Use Reverse 10.0.7.202:80 admin@xxxxxxxx 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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux