LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-03-2014, 05:27 PM   #1
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: CentOS, MacOS, [Open]SuSE, Raspian, Red Hat, Slackware, Solaris, Tru64
Posts: 1,503

Rep: Reputation: 167Reputation: 167
Looking for tips on running Apache named virtual hosts assigned to an alias


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

Last edited by rnturn; 09-04-2014 at 11:26 AM. Reason: Updated with new info
 
Old 09-08-2014, 05:18 PM   #2
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: CentOS, MacOS, [Open]SuSE, Raspian, Red Hat, Slackware, Solaris, Tru64
Posts: 1,503

Original Poster
Rep: Reputation: 167Reputation: 167
Calling this solved...

... though I'm not at all satisfied by the solution[*].

After trying everything I could find online to make named virtual hosts work on the Apache 2.2 software -- including recompiling it from the sources and going over the output of make with a fine-toothed comb to look for anything that might have gone wrong... and finding nothing -- I finally bit the bullet and downloaded the latest source tar archive (2.4.10) and rebuilt Apache from scratch. Now name virtual hosts work like a charm (like I remember them working back in the 1.x days). In fact, it was hard to make them not work. Another nice thing about the newest version is that the error messages out of apachectl are much, much more useful should you mistype something in one of the configuration files.

Calling this one solved.

--
[*] - It was due for an upgrade anyway.

Last edited by rnturn; 09-08-2014 at 05:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache and Named Virtual Hosts Giving 403 Forbidden Error durus123 Linux - Server 1 09-05-2009 05:24 AM
how do i set up apache, to be running with 2 virtual hosts, using fedora 8, im a newb slickrdm@hotmail.com Linux - Newbie 1 05-03-2009 07:00 PM
Apache and Named Virtual Hosts Giving 403 Forbidden Error PekinSOFT Linux - Server 2 04-15-2009 01:07 AM
Apache named virtual host config darthtux Linux - Software 8 04-19-2005 02:38 AM
RH9 & Apache Named Based Virt Hosts mwmethe Linux - Networking 1 11-03-2003 09:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration