We have a couple of complex virtual host definitions in our httpd.conf file.
What I mean by that is:
<VirtualHost .....>
....
</VirtualHost>
What I mean by complex is that they are full of rewrite rules and such.
We would like to bind this virtual host on 2 ip addresses. Currently it is bound only to one.
Is it possible to bind a virtual host to 2 ip addresses using a single VirtualHost?
It would make things a lot easier to have a single one if we need to make changes in the future.
You can just place multiple IP/Port specifiers in the definition, as described in the documentation.
Example:
Just make sure you've got Apache configured with enough NameVirtualHost definitions.
Sure:
Alternatively, consider using name-based virtual hosts instead.
You could use...
..to bind to any IP on the server
An easy way to handle this is to extract the common bits into a separate file (e.g.,
/path/to/foo
) and thenInclude
it in your vhost defs:Note: Do not put
/path/to/foo
somewhere that will be pulled in by a wildcardInclude
elsewhere.I would probably go with the named virtual hosts, AND make the modification to the DNS so that both IPs have A records with the same hostname.