default web site always the last virtual

6 posts / 0 new
Last post
#1 Thu, 05/22/2008 - 22:14
Hal9000

default web site always the last virtual

Hello! I am setting up Virtualmin Pro these days (really impressive), and have come across this problem: the web site that will show up for domains that point to the server, but have no virtual servers configured in apache, is always the latest virtual that has been added. so for example, the hostname of my server, which does not have any web site, will show the website of the latest domain i added to virtualmin hosting. hopefully you understand what i mean. i want that the default apache website be always a specific one, where i can show something like "domain not active on this server" or stuff like that. how can i achieve this? thanks :)

Sat, 05/24/2008 - 03:17
ronald
ronald's picture

by default the IP shows the toplisted virtual domain. At least this was/is so on my server. centos 5.1 VM Pro 3.57

In the - Apache webserver module - global configuration - edit config files - find these lines

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
<b># The first VirtualHost section is used for requests without a known
# server name.</b>
#
#&lt;VirtualHost *:80&gt;
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#&lt;/VirtualHost&gt;

Make sure the dummy server/domein exists and put it on top of the list.&lt;br&gt;&lt;br&gt;Post edited by: ronald, at: 2008/05/24 03:18

Sat, 05/24/2008 - 23:16 (Reply to #2)
Hal9000

hmmm i have no such lines.
anyway, if i look at &quot;existing virtual hosts&quot;, i can see two entries at the top:

Default Server Any Any Automatic Automatic
Virtual Server Any Any Automatic /var/www/

But somehow they don't seem to work...

Tue, 05/27/2008 - 08:14 (Reply to #3)
Hal9000

Debian 4.0 here.

<div class='quote'>hannibal:/etc/apache2/sites-enabled# ls -l
total 28
lrwxrwxrwx 1 root root 36 2008-05-19 21:28 000-default -&gt; /etc/apache2/sites-available/default
</div>

i seem to have a dummy configuration and it is the very first in the list, but instead, the second virtual in the list is used as default hosting.

so there must be some error in the default virtual config i guess...

<div class='quote'>NameVirtualHost *
NameVirtualHost xxx.xxx.xxx.xxx:80
&lt;VirtualHost *&gt;
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
&lt;Directory /&gt;
Options FollowSymLinks
AllowOverride None
&lt;/Directory&gt;
&lt;Directory /var/www/&gt;
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
&lt;/Directory&gt;

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
&lt;Directory &quot;/usr/lib/cgi-bin&quot;&gt;
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
&lt;/Directory&gt;

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ &quot;/usr/share/doc/&quot;
&lt;Directory &quot;/usr/share/doc/&quot;&gt;
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
&lt;/Directory&gt;

&lt;/VirtualHost&gt;
</div>

Any clue?
I'm still in the process of migrating my domain and find this issue really annoying, I want to fix this :)

hal

Tue, 05/27/2008 - 09:20 (Reply to #4)
ronald
ronald's picture

what I did actually was to manually edit the apache config and placed my main domain at the top of the &lt;virtualhost&gt; list.
If any existing domain has a wrong in it then my main domain will show up (in my case it is a hosting promotional domain ;)

since you are on debian I can't share my experience as I run on CentOS, however per haps the http://www.virtualmin.com/documentation/id,troubleshooting_common_problems/ can help a little. There is a section about wrong sites showing up when scrolling down.

Tue, 05/27/2008 - 10:47 (Reply to #5)
Hal9000

Thanks! That did the trick!
I changed
<div class='quote'>
NameVirtualHost *
NameVirtualHost xxx.xxx.xxx.xxx:80
&lt;VirtualHost *&gt;
</div>

to

<div class='quote'>
NameVirtualHost xxx.xxx.xxx.xxx:80
&lt;VirtualHost xxx.xxx.xxx.xxx:80&gt;
</div>

and also created a virtualhost for port 443

hal

Topic locked