I've been trying to work through an example in the Apache Cookbook (2004 edition but the Apache manual directive descriptions for 2.2 and 2.4 seem identical) that shows where one can have named virtual hosts accessed through one IP address and others accessed via a different IP address.
NOTE: Updated. See the bottom for additional info...
I have a group of virtual hosts that I want to be accessible to the general public (the firewall will direct port 80 traffic to this IP address) and another set that are only known to users inside the firewall that will respond to requests on a second IP address (alias).
I'm using (or trying to, anyway) the example entitled ``Mixing Address-Based and Name-Based Virtual Hosts''. When I tweak my config files (these all used to define address-based vhosts; I'm attempting to migrate them) and start Apache I get a slew of error messages. The same messages are displayed when I run `apachectl -S'. A sample of the messages is:
Code:
[warn] VirtualHost 192.168.13.100:80 overlaps with VirtualHost 192.168.13.100:80, the first has precedence, perhaps you need a NameVirtualHost directive
[warn] VirtualHost 192.168.13.100:80 overlaps with VirtualHost 192.168.13.100:80, the first has precedence, perhaps you need a NameVirtualHost directive
[warn] VirtualHost 192.168.13.200:80 overlaps with VirtualHost 192.168.13.200:80, the first has precedence, perhaps you need a NameVirtualHost directive
[warn] VirtualHost 192.168.13.200:80 overlaps with VirtualHost 192.168.13.200:80, the first has precedence, perhaps you need a NameVirtualHost directive
Then the actual virtual host configuration is listed and only the first defined virtual host for each IP address is listed.
In the file `httpd-vhosts.conf' I have directives like:
Code:
NameVirtualHost 192.168.13.100
Include vhosts.d/public.*.conf
(The publicly accessible virtual hosts are defined in files with the `public.' prefix. A similar pair of statements (but with a `.200' address) are supposed to define the second IP address to be used by the internal virtual hosts (using config files prefixed with `internal.').
Each publicly accessible virtual host has the following directives at the top:
Code:
<VirtualHost 192.168.13.100>
ServerAdmin my@email.address
ServerName public_site_name
DocumentRoot /var/app/httpd/vhosts/public_site_name/public_html
.
.
.
</VirtualHost>
(The vhosts that I want to be accessible internally have the `.200' address in the VirtualHost directive.) I've tried changing `VirtualHost' to `NameVirtualHost' in each of the vhost config files (as suggested by the original error messages) but that results in a different error message:
Code:
Invalid command '<NameVirtualHost', perhaps misspelled or defined by a module not included in the server configuration
I didn't really expect that to work but tried it anyway. The httpd-vhosts.conf file has all the NameVirtualHost directives I need. (I think.)
Ideas?
Is the text wrong and this combination of address-based and name-based isn't actually possible? The manual for Apache seems to indicate that it is so I'm a bit confused why these error messages are appearing.
Might I be missing a necessary module to support this configuration? The list of compiled-in modules is:
Code:
Compiled in modules:
core.c
mod_authn_file.c
mod_authn_default.c
mod_authz_host.c
mod_authz_groupfile.c
mod_authz_user.c
mod_authz_default.c
mod_auth_basic.c
mod_include.c
mod_filter.c
mod_log_config.c
mod_env.c
mod_setenvif.c
mod_version.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_so.c
I thought `mod_alias' would be all that's needed.
Update (2014-09-04): Rather than use:
Code:
NameVirtualHost 192.168.13.100:80
<VirtualHost 192.168.13.100:80>
ServerName site1.org
...
</VirtualHost>
<VirtualHost 192.168.13.100:80>
ServerName site2.org
...
</VirtualHost>
<VirtualHost 192.168.13.100:80>
ServerName site2.com
...
</VirtualHost>
NameVirtualHost 192.168.13.200:80
<VirtualHost 192.168.13.200:80>
ServerName internal1.net
...
</VirtualHost>
Which does not work despite all the Apache documentation that states otherwise (all it results in is multiple error messages about overlayed virtual hosts -- shown above, BTW -- and only the first vhost being defined on the ".100" address, I changed all of the definitions to look like:
Code:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName site1.org
...
</VirtualHost>
<VirtualHost *:80>
ServerName site2.org
...
</VirtualHost>
<VirtualHost *:80>
ServerName site2.com
...
</VirtualHost>
NameVirtualHost 192.168.13.200:80
<VirtualHost 192.168.13.200:80>
ServerName internal1.net
...
</VirtualHost>
This eliminated the error messages BUT I can only access the
first vhost on the ".100" address. Any attempts to connect to the other vhosts take me to the first defined vhost. Curiouser and curiouser...
Any and all help is greatly welcomed.
And, as usual, TIA...
--
Rick