LinuxQuestions.org
Review your favorite Linux distribution.
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 05-20-2009, 11:46 AM   #1
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Rep: Reputation: 31
Question wrong vhost reported as default by Apache


Trying to make sense of an Apache configuration that's all over the map. The relevant files are:
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/*.conf (several files, including ssl.conf)
/etc/httpd/virtualhosts.d/*.conf (1 file)

The files in conf.d/ and virtualhosts.d/ are pulled in via Include directives after NameVirtualHost *:80, and two vhosts are also defined in httpd.conf itself.

I would like the server defined by a virtual host in ssl.conf to be considered the "default" server, meaning if Apache reports a server error or other problem, I would like it to come on behalf of this server. The main problem is that even though the vhost in ssl.conf is defined with <VirtualHost _default_:443>, one of the non-SSL vhosts (the one in virtualhosts.d/, actually) shows up as the server name in client error messages (Not found, Forbidden, etc.).

Apache says the config syntax is okay and reports the following:
Code:
# apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          main.site.com (/etc/httpd/conf.d/ssl.conf:88)
*:80                   is a NameVirtualHost
         default server some.vhost.com (/etc/httpd/virtualhost.d/some.vhost.com-80:1)
         port 80 namevhost some.vhost.com (/etc/httpd/virtualhost.d/some.vhost.com-80:1)
         port 80 namevhost another.virtualhost.com (/etc/httpd/conf/httpd.conf:1028)
         port 80 namevhost main.site.com (/etc/httpd/conf/httpd.conf:1040)
Here, main.site.com:443 is correctly defined as _default_, but some.vhost.com shows up as the "default server" and the server name displayed in error messages. main.site.com:80 contains only a rewrite to send all requests to port 443. I tried adding a default directive there, in case a default on port 80 was required, but Apache returned warnings:
Code:
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
[warn] NameVirtualHost *:80 has no VirtualHosts
Is there a way to tell Apache to return the _default_:443 vhost as the "default server"?
 
Old 05-20-2009, 02:08 PM   #2
archangel_617b
Member
 
Registered: Sep 2003
Location: GMT -08:00
Distribution: Ubuntu, RHEL/CentOS, Fedora
Posts: 234

Rep: Reputation: 42
Quote:
Originally Posted by deesto View Post
Is there a way to tell Apache to return the _default_:443 vhost as the "default server"?
The short answer is "no".

The longer explanation is that there are two parts: your standard port 80 and your HTTPS on port 443. Virtual hosts have different IPs or ports. So you have basically two "real" hosts, one on port 80 and the other on port 443. On port 80, it's just picking your first port 80 virtual host as the default (my guess).

On port 443, you've only got one virtual host so you wouldn't have anything that wasn't default anyhow.

So to me it looks like you need to remove the "_default_" statement from your port 443 host and then I think your port 80 one should work and successfully redirect clients to the HTTPS site.

Hope this helps,

- Arch
 
Old 05-21-2009, 09:00 AM   #3
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Original Poster
Rep: Reputation: 31
Thanks Arch. Makes sense, though I wish Apache's configuration didn't work that way. Still, I've tried to fix it by removing the _default_ definition from the vhost in ssl.conf, and adding it to the vhost on port 80 in httpd.conf that redirects to 443. Yet it looks like nothing changed: Apache still reports the "default server" to be the one defined in virtualhost.d/ . Is this because its Include directive occurs physically before the others in httpd.conf? If so, I may have a problem, as I need the last host to serve as a fall-through, such that any requests not addressed in previous vhost definitions would be redirected to the SSL port.
 
Old 05-21-2009, 11:29 AM   #4
archangel_617b
Member
 
Registered: Sep 2003
Location: GMT -08:00
Distribution: Ubuntu, RHEL/CentOS, Fedora
Posts: 234

Rep: Reputation: 42
Hm, yeah I've had issues too with how apache picks the virtual host. At some point, I basically resorted to stacking my vhosts such that the one I wanted as the default was included first in the apache config.

- Arch
 
  


Reply

Tags
apache, default, hosts, server, ssl, virtual


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
AWStats on Apache vhost. What am I doing wrong? koobi Linux - Server 2 10-16-2007 10:32 AM
Wrong HardDrive Space Being Reported wfernley Linux - Software 7 03-01-2006 02:01 PM
Apache: Alias is working on ssl vhost but not on mass vhost jonavogt Linux - Software 0 06-07-2005 03:05 PM


All times are GMT -5. The time now is 06:00 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration