Skip to content
Snippets Groups Projects
Commit 9126cdfe authored by Thomas Bellman's avatar Thomas Bellman
Browse files

named_vhost: Allow overriding auto-listen.

Having the named_vhost definition automatically configure Apache to
listen on the address/port pairs used by the virtual host, is usually
helpful.  There are occasions, however, when it will give unwanted
results, or even break things.  In particular, if you have overlaps,
with one virtual host handling a specific address, and one handling
the "wildcard" address (e.g. https://*/), you can't have Apache listen
to both INADDR_ANY and a specific address.  There may be other cases
where users want more control as well.

We here introduce a new parameter 'listen' on the apache::named_vhost
definition, which specifies addresses (URLs) that Apache httpd should
be configured to listen on.  If not specified, it defaults to using
the same set of addresses as specified by the 'urls' parameter, so in
many cases users won't need to specify it.
parent 070d2952
No related branches found
No related tags found
No related merge requests found
...@@ -10,12 +10,17 @@ ...@@ -10,12 +10,17 @@
* - urls * - urls
* Specifies one or more addresses that this virtual host handles, i.e. * Specifies one or more addresses that this virtual host handles, i.e.
* which 'Listen' directives apply to it, on the format of URLs, in the * which 'Listen' directives apply to it, on the format of URLs, in the
* same format as apache::listen does. apache::listen will be called * same format as apache::listen does. apache::listen will by default
* automatically, so you don't need to do that separately (this is a new * be called automatically, so you don't need to do that separately
* behaviour since 2024). * (this is a new behaviour since 2024).
* This parameter can be either a single URL, or a (possibly nested) * This parameter can be either a single URL, or a (possibly nested)
* list of URLs. * list of URLs.
* *
* - listen
* URLs to listen to, using apache::listen. This will use the value of
* the 'urls' parameter as its default value. Specify the empty list if
* you do not want to generate any Listen directives automatically.
*
* - servernames * - servernames
* Which hostnames in URLs this virtual host applies to. Translates * Which hostnames in URLs this virtual host applies to. Translates
* into 'ServerName' and 'ServerAlias' directives. Defaults to the * into 'ServerName' and 'ServerAlias' directives. Defaults to the
...@@ -50,6 +55,7 @@ ...@@ -50,6 +55,7 @@
# e.g. http over https. # e.g. http over https.
define apache::named_vhost($urls, define apache::named_vhost($urls,
$listen=undef,
$servernames=[], $servernames=[],
$certname=false, $certname=false,
$documentroot='', $documentroot='',
...@@ -69,7 +75,7 @@ define apache::named_vhost($urls, ...@@ -69,7 +75,7 @@ define apache::named_vhost($urls,
} }
apache::listen { apache::listen {
"_vhost-${name}": "_vhost-${name}":
urls => $urls; urls => $listen ? { undef => $urls, default => $listen };
} }
apache::include_file { apache::include_file {
"vhost-${name}": "vhost-${name}":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment