Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-11-2008, 02:49 PM   #1
LQ Newbie
Registered: Jan 2006
Distribution: Debian
Posts: 12

Rep: Reputation: 0
Apache2 is serving single NameVirtualHost for all names

I have an Apache2 server running on Debian Etch. I want to get rid of the default website... so that if someone surfs to the machine via some domain name I have NOT yet configured, the Apache server will return a "document not found" error.

I have configured one single file in /etc/apache2/sites-available to run as a virtual host. I have enabled this file (the link is in sites-enabled) and I have also DISABLED the 000-default file. When I run my server and point to the proper virtual host name ( ,which was configured for in the single virtual host file mentioned earlier), Apache serves the correct file. However, if I point to or (both which resolve to the same IP address as then Apache serves the files... almost like it's using that virtual host name as the "default" site to serve.

On the Apache2 documentation, it specifially says,
Note, that the "main server" and any _default_ servers will never be served for a request to a NameVirtualHost IP address (unless for some reason you specify NameVirtualHost but then don't define any VirtualHosts for that address).
How should I have my virtual host file configured so that it is NOT used as the default dropping site for other domain names that point to that same machine?

Thanks in advance!
Old 06-11-2008, 03:08 PM   #2
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,487

Rep: Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627Reputation: 627
It would have helped if you had posted the sites-available file in your post as well.

My guess is that you left a serveralias in with an asterisk somewhere.

Old 06-12-2008, 09:51 AM   #3
LQ Newbie
Registered: Jan 2006
Distribution: Debian
Posts: 12

Original Poster
Rep: Reputation: 0
Sorry, here is what the sites-available file looked like:

NameVirtualHost *
<VirtualHost *>
        DocumentRoot /var/www/html/
        <Directory /var/www/html/>
                Options FollowSymLinks
                AllowOverride None

        ErrorLog /var/log/apache2/error.log
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
Old 06-12-2008, 10:08 AM   #4
LQ Guru
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,232
Blog Entries: 5

Rep: Reputation: 190Reputation: 190
Looks like the proper operation of the server per the docs..


For any undefined ServerName fields, a name-based vhost defaults to the address given first in the VirtualHost statement defining the vhost.

Name-based vhost

If the entry corresponds to a name-based vhost the name list contains one or more vhost structures. This list contains the vhosts in the same order as the VirtualHost directives appear in the config file.

The first vhost on this list (the first vhost in the config file with the specified IP address) has the highest priority and catches any request to an unknown server name or a request without a Host: header field.

If the client provided a Host: header field the list is searched for a matching vhost and the first hit on a ServerName or ServerAlias is taken and the request is served from that vhost. A Host: header field can contain a port number, but Apache always matches against the real port to which the client sent the request.

If the client submitted a HTTP/1.0 request without Host: header field we don't know to what server the client tried to connect and any existing ServerPath is matched against the URI from the request. The first matching path on the list is used and the request is served from that vhost.

If no matching vhost could be found the request is served from the first vhost with a matching port number that is on the list for the IP to which the client connected (as already mentioned before).
Old 06-12-2008, 10:33 AM   #5
LQ Newbie
Registered: Jan 2006
Distribution: Debian
Posts: 12

Original Poster
Rep: Reputation: 0

aaah so it takes the first one, according to the "order listed", as the default.

Thanks for that response!


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
Apache2 NameVirtualHost not working intramaweb Linux - Server 7 12-12-2007 07:59 AM
apache2 error - namevirtualhost *:0 has no virtualhosts? tiger.woods Ubuntu 2 04-09-2007 10:26 AM
apache2 serving <username>'s page radiodee1 Linux - Newbie 1 04-05-2007 04:10 PM
apache2 NameVirtualHost gabsik Linux - Networking 3 01-18-2007 02:26 PM
Apache2 running but not serving any page Kerion Linux - Newbie 4 07-28-2004 05:16 PM

All times are GMT -5. The time now is 04:05 AM.

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