Name
Per-Server Merger
Synopsis
void *module_merge_server(pool *pPool, void *base_conf, void *new_conf)
Once the Config
files
have been read, this function is called once for each virtual host,
with base_conf
pointing to the main
server’s configuration (for this module) and
new_conf
pointing to the virtual
host’s configuration. This gives you the opportunity
to inherit any unset options in the virtual host from the main server
or to merge the main server’s entries into the
virtual server, if appropriate. It returns a pointer to the new
configuration structure for the virtual host (or it just returns
new_conf
, if appropriate).
It is possible that future changes to Apache will allow merging of
hosts other than the main one, so don’t rely on
base_conf
pointing to the main server. See Example 21-4 (1.3) for an excerpt from
mod_cgi.c.
Example
static void *merge_cgi_config(pool *p, void *basev, void *overridesv) { cgi_server_conf *base = (cgi_server_conf *) basev, *overrides = (cgi_server_conf *) overridesv; return overrides->logname ? overrides : base; }
Although this example is exceedingly trivial, a per-server merger
can, in principle, do anything a per-directory merger
does — it’s just that in most cases it makes
more sense to do things per-directory, so the interesting examples
can be found there. This example does serve to illustrate a point of
confusion — often the overriding configuration is called
overrides
(or some variant thereof), which to our ears ...
Get Apache: The Definitive Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.