Apache 1 virtual host definition listening on 2 ips - how?

Solution 1:

An easy way to handle this is to extract the common bits into a separate file (e.g., /path/to/foo) and then Include it in your vhost defs:

<Vitrualhost ...>
  ServerName X
  DocumentRoot Y
  Include /path/to/foo
</Virtualhost>

<Vitrualhost ...>
  ServerName Z
  DocumentRoot A
  Include /path/to/foo
</Virtualhost>

Note: Do not put /path/to/foo somewhere that will be pulled in by a wildcard Include elsewhere.

Solution 2:

You can just place multiple IP/Port specifiers in the definition, as described in the documentation.

Example:

<VirtualHost 1.2.3.4:80 2.3.4.5:80 1.2.3.4:8080>
DocumentRoot /path/to/wherever
ServerName example.com
# Stuff goes here
</VirtualHost>

Just make sure you've got Apache configured with enough NameVirtualHost definitions.

Solution 3:

Sure:

Listen 80

<VirtualHost _default_:80>
    ...
</VirtualHost>

Alternatively, consider using name-based virtual hosts instead.

Solution 4:

You could use...

Listen 80

<VirtualHost *:80>
...
</VirtualHost>

..to bind to any IP on the server