Welcome, Guest
Please Login or Register.
Lost Password?
Re:Set Default Virtual Host (1 viewing)
Post Reply

TOPIC: Re:Set Default Virtual Host

#15735
notacake (User)
Posts: 3
graphgraph
Set Default Virtual Host 2008/08/18 02:55  
How can I set a named virtual host to be the default?
At the moment when I go to the IP address it comes up with a seemingly random virtual host (always the same one, but it wasn't the first or the last that was created - which would have made some kind of sense).

I've tried changing the *:80 virtual host in the Apache module, yet it doesn't seem to have any effect. I can't figure out where it's deciding which is the default.
  The administrator has disabled public write access.
#15736
andreychek (Moderator)
Posts: 585
graphgraph
Re:Set Default Virtual Host 2008/08/18 04:45  
In theory, it should be the first one it comes to.

In RHEL/CentOS, where all the VirtualHosts go in the httpd.conf file, the first VirtualHost section should become the "default".

In Ubuntu, there's a file named /etc/apache2/enabled-sites/000-default.conf -- whatever the contents it are becomes the default Virtual Host.

It shouldn't be random though unless somehow the order of the VirtualHost directives is changing.
-Eric
  The administrator has disabled public write access.
#15737
notacake (User)
Posts: 3
graphgraph
Re:Set Default Virtual Host 2008/08/18 05:40  
The 000-default.conf is set up to use the document root I want, yet it still uses a different virtual host.

The virtual host it's using seems to be the first alphabetically based on subdomains, i.e. 'dev.a.com' is being shown as the default, even though there's an 'a.com'.
  The administrator has disabled public write access.
#15747
Joe (Admin)
Posts: 4082
graph
Re:Set Default Virtual Host 2008/08/18 08:10  
It selects in a "first best match" manner. If the 000-default.conf virtual host is a *:80 address, and all of your virtual hosts are 192.168.1.1:80 style, then when you hit 192.168.1.1, one of those will win the selection process.

We do not recommend you use * for any virtual host for this reason (and others). It makes it difficult to predict and understand what Apache is doing and why.
  The administrator has disabled public write access.
#15748
notacake (User)
Posts: 3
graphgraph
Re:Set Default Virtual Host 2008/08/18 09:09  
Thank you! That did the trick.
  The administrator has disabled public write access.
Post Reply
get the latest posts directly to your desktop

Talk and Get Help

Support
Forums
Bugs and Issues

Get Virtualmin

OS Support
Buy Online
Download
Copyright 2005-2007 Virtualmin, Inc. All rights reserved.