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. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-11-2008, 02:49 PM
|
#1
|
|
LQ Newbie
Registered: Jan 2006
Distribution: Debian
Posts: 12
Rep:
|
Apache2 is serving single NameVirtualHost for all names
Hi,
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 (www.mydomain.com ,which was configured for in the single virtual host file mentioned earlier), Apache serves the correct file. However, if I point to first.mydomain.com or anything.mydomain.com (both which resolve to the same IP address as www.mydomain.com) then Apache serves the www.mydomain.com files... almost like it's using that virtual host name as the "default" site to serve.
On the Apache2 documentation, http://httpd.apache.org/docs/2.0/mod...amevirtualhost it specifially says,
Quote:
Note
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!
|
|
|
|
06-11-2008, 03:08 PM
|
#2
|
|
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 3,832
|
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.
jlinkels
|
|
|
|
06-12-2008, 09:51 AM
|
#3
|
|
LQ Newbie
Registered: Jan 2006
Distribution: Debian
Posts: 12
Original Poster
Rep:
|
Sorry, here is what the sites-available file looked like:
Code:
NameVirtualHost *
<VirtualHost *>
ServerAdmin r3gan@mydomain.com
ServerName www.mydomain.com
DocumentRoot /var/www/html/
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride None
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
|
|
|
|
06-12-2008, 10:08 AM
|
#4
|
|
Guru
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,231
Rep: 
|
Looks like the proper operation of the server per the docs..
http://httpd.apache.org/docs/2.0/vhosts/name-based.html
http://httpd.apache.org/docs/2.0/vhosts/ip-based.html
Quote:
http://httpd.apache.org/docs/2.0/vhosts/details.html
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).
|
|
|
|
|
06-12-2008, 10:33 AM
|
#5
|
|
LQ Newbie
Registered: Jan 2006
Distribution: Debian
Posts: 12
Original Poster
Rep:
|
aaah so it takes the first one, according to the "order listed", as the default.
Thanks for that response!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:22 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|