mod_macro Provides macros within apache httpd runtime configuration files Base mod_macro.c macro_module

This modules provides macros within apache httpd runtime configuration files. These macros may have parameters. They are expanded when used (parameters are substituted by their values given as an argument), and the result is processed normally.

Features

Definition of a macro:

Use of a macro:

Removal of a macro definition:

<Macro DirGroup $dir $group> <Directory $dir> require group $group </Directory> </Macro> Use DirGroup /www/apache/private private Use DirGroup /www/apache/server admin UndefMacro DirGroup
Examples

A common usage of mod_macro is for the creation of dynamically-generated virtual hosts.

## Define a VHost Macro for repetitive configurations <Macro VHost $host $port $dir> Listen $port <VirtualHost *:$port> ServerName $host DocumentRoot $dir <Directory $dir> # do something here... </Directory> # limit access to intranet subdir. <Directory $dir/intranet> Require ip 10.0.0.0/8 </Directory> </VirtualHost> </Macro> ## Use of VHost with different arguments. Use VHost www.apache.org 80 /vhosts/apache/htdocs Use VHost example.org 8080 /vhosts/example/htdocs Use VHost www.example.fr 1234 /vhosts/example.fr/htdocs
Macro Define a configuration file macro <Macro name [par1 .. parN]> ... </Macro> server config virtual host directory

The Macro directive controls the definition of a macro within the server runtime configuration files. The first argument is the name of the macro. Other arguments are parameters to the macro. It is good practice to prefix parameter names with any of '$%@', and not macro names with such characters.

<Macro LocalAccessPolicy> Require ip 10.2.16.0/24 </Macro> <Macro RestrictedAccessPolicy $ipnumbers> Require ip $ipnumbers </Macro>
Use Use a macro Use name [value1 ... valueN] server config virtual host directory

The Use directive controls the use of a macro. The specified macro is expanded. It must be given the same number of arguments than in the macro definition. The provided values are associated to their corresponding initial parameters and are substituted before processing.

Use LocalAccessPolicy ... Use RestrictedAccessPolicy "192.54.172.0/24 192.54.148.0/24"

is equivalent, with the macros defined above, to:

Require ip 10.2.16.0/24 ... Require ip 192.54.172.0/24 192.54.148.0/24
UndefMacro Undefine a macro UndefMacro name server config virtual host directory

The UndefMacro directive undefines a macro which has been defined before hand.

UndefMacro LocalAccessPolicy UndefMacro RestrictedAccessPolicy