Default Virtual Server

8 posts / 0 new
Last post
#1 Wed, 11/26/2008 - 04:18
toddgeist

Default Virtual Server

Hello,

I am a new user of Webmin + Virtualmin. I installed it and used for a month without problem but I have a small question.

When I go to http://[IP_of_the_server/, I got the first virtual server. Is there a way to change that behavior by displaying a custom virtual server ?

I searched through the forum for 'fallback or default virtual server' but no answer to my question.

Thanks a lot,

Tristan

Wed, 04/16/2008 - 08:47
DanLong

easiest way? Make example.com the first server in the list of shared IP servers. THere isn't a default www anymore so Apache will take the first listed.

Hope that helps,
Dan

Wed, 04/16/2008 - 19:10
toddgeist

Thank you, I had forgotten about that.

Wed, 11/26/2008 - 04:33
andreychek

Hi Tristan,

I'm not aware of a way to get Virtualmin to do this for you, but all you need to do is re-order the Apache config such that your preferred Virtual Server is listed in it first.

If you'd like to be able to see Virtualmin do that, feel free to file a feature request in the Bugs and Issues tracker below -- but in the meantime moving your preferred VirtualHost line to the top will do what you're after.
-Eric

Wed, 12/24/2008 - 04:49 (Reply to #4)
alfredolo

I got a work around..

Just make a new virtual server called "000.com" so this will be the first in sites-available..

For a redirection create a index.php file into it and write :
<?php
header( 'Location:http://www.yoursite.com/');
?>

This work fine for me.
Hope this can help

Wed, 11/26/2008 - 22:35
tristanleboss

Thanks for your reply, Eric.

Indeed, the solution you gave me seems to be the easiest way to do what I want. I just encounter a problem : you do I re-order virtual servers : the file "/etc/apache2/httpd.conf" is empty and the VirtualServer directives are stored in individuals files in the folder "/etc/apache2/sites-available" ?

Regarding the feature, I think the behavior of Virtualmin in this case is strange : on a clean install without any domain, Virtualmin displays a page saying 'It works!'. After investigation, this is the content of the 'default' virtual server (/etc/apache2/sites-available/default).
Then, once a domain is created, this default virtual server seems to be lost and Virtualmin, probably after trying each virtual server, fallbacks on the first one even if nor the ServerName or the ServerAlias match.

Tristan

Wed, 11/26/2008 - 22:50 (Reply to #6)
Joe
Joe's picture

<div class='quote'>Regarding the feature, I think the behavior of Virtualmin in this case is strange : on a clean install without any domain, Virtualmin displays a page saying 'It works!'. After investigation, this is the content of the 'default' virtual server (/etc/apache2/sites-available/default).
Then, once a domain is created, this default virtual server seems to be lost and Virtualmin, probably after trying each virtual server, fallbacks on the first one even if nor the ServerName or the ServerAlias match.</div>

Virtualmin has nothing to do with this. This is all standard, well-documented Apache behavior.

Apache has two modes of operation. One for serving a single website, and one for name-based virtual hosting. When Apache is configured for name-based virtual hosting, the word &quot;default&quot; has no meaning anymore. There is simply no such thing as a &quot;default&quot; site in an Apache virtual hosting configuration.

Apache will server the first-best match for any given request. You can make the first-best match for non-matching situations (like when you use an IP) be a particular site by making sure it is the first one loaded (prepend 00 to the name of the file you want to be &quot;first&quot;, for example), but it's never going to make it a &quot;default&quot; site.

What I'm saying is that a reasonable approximation of a &quot;default&quot; site can be made by renaming the site you'd like to show up when nothing matches &quot;best&quot; to something like 00-domain.conf in /etc/apache2/sites-available/.

However, a better practice is to never expect the IP address to be meaningful. Just don't use an IP address at all. Use a name, always, and Apache will always know exactly what site you wanted. That's why we have DNS! ;-)

--

Check out the forum guidelines!

Sun, 11/30/2008 - 06:04
tristanleboss

Joe, thanks for your explanation and for the tip to help me doing what I want.

I don't use the server IP but if someone try, I just prefer to display a blank page or a short message saying the server is hosting multiple site: not having one site of my customers poping-up.

Topic locked