All Virtual servers go to /apache2-default/

13 posts / 0 new
Last post
#1 Fri, 05/01/2009 - 16:48
Slayerduck

All Virtual servers go to /apache2-default/

I installed Virtualmin 3.68 on a clean Debian 4.0 vps. Then i added a virtual server and sub domain for it. Both the main and sub virtual server do not work, they always redirect to /apache2-default/

When i look at the apache2 virtual hosts in webmin everything looks like its redirecting to the right folders and such.

What am i doing wrong ?

IP: 83.149.71.246 Domain: slayerduck.net Sub: upload.slayerduck.net OS: Debian 4.0

Fri, 05/01/2009 - 16:55
andreychek

What does this file look like:

/etc/apache2/sites-enabled/000-default

Sat, 05/02/2009 - 02:52
Slayerduck

NameVirtualHost *
NameVirtualHost ::1:80
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
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/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

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/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Sat, 05/02/2009 - 03:22 (Reply to #3)
Joe
Joe's picture

http://www.virtualmin.com/documentation/id,troubleshooting_common_proble...

You don't want * or NameVirtualHost ::1:80 in a virtual hosting environment. It's really difficult to get it right. If you always use IPs and explicit ports, you won't end up with sites showing up in places you don't think they should (but Apache disagrees...and Apache is always right).

--

Check out the forum guidelines!

Sat, 05/02/2009 - 03:38 (Reply to #4)
Slayerduck

So what do i do here? Sorry buy im totally new at this. I removed the NameVirtualHost *
NameVirtualHost ::1:80

from the conf and restarted the apache buy its still the same. And how do i make it so every default request goes to slayerduck.net and not apache2-default?

Sat, 05/02/2009 - 09:42 (Reply to #5)
andreychek

Howdy,

First, if that VirtualHost section still reads "<VirtualHost *>", that may cause trouble still, ou'll want to change that to "<VirtualHost x.y.z.q:80>", where "x.y.z.q" is your IP address.

However, there still remains a problem for you, in that I believe Apache always uses the first VirtualHost line as the default site to display.

So to fix the default, you'd either need to change the order Apache sees the Virtual Host sections, or you could add a direct into /apache-default/ to redirect to the site you wish to be the default.

It's possible Virtualmin offers a simpler way to fix that issue, but I'm not quite sure what it is :-)
-Eric

Sat, 05/02/2009 - 12:14 (Reply to #6)
Joe
Joe's picture

Virtualmin 3.68 introduced a "default" site juggler. It'll move the site marked default to the top of the list. I don't actually know where that option is, but I saw the SVN checkin of the code to do it...so I know it's in there.

I didn't think we were trying to do "default" here, though...I thought we were trying to fix "all virtual servers go to apache2-default". Which is a symptom of having the "default" (or any generic * NameVirtualHost/VirtualHost) server suck up everything else that doesn't have a first-best match on the domain.

So, you need to remove all instances of non-specific NameVirtualHosts, which looks like this:

NameVirtualHost *

And make sure you have a NameVirtualHost for each IP you intend to use, which should look like this:

NameVirtualHost 192.168.1.1:80

And make sure all VirtualHost sections are pointing to specific, rather than generic addresses.

If it looks like this, it is wrong:

<VirtualHost *:80>

Or:

<VirtualHost *>

It needs to look like this:

<VirtualHost 192.168.1.1:80>

--

Check out the forum guidelines!

Sat, 05/02/2009 - 13:30
Slayerduck

it works now, thanks ;)

Tue, 05/26/2009 - 08:52
justinwpw

Hi,

I also am experiencing this problem. I think it coincided with a recent Apache2 update.

In my case, I have 3 domains, each one using SSL websites. The first one was installed on internal ip address 192.168.1.65, the other two had to be installed by Virtualmin using virtual ip's.

All three webservers point to the domain on internal ip address 192.168.1.65. As far as I can see, Virtualmin has set them up correctly with their own public_html directories, but they are not using them. I've checked by placing an index.html file in each - they only show that page when it is in the public_html directory belonging to the first domain on 192.168.1.65.

I've checked the apache2-default file and removed any NameVirtualhost * and explicitly stated all the ip addresses I'm using as follows:

NameVirtualHost 192.168.1.65:80
NameVirtualHost 192.168.1.65:443
NameVirtualHost 192.168.1.70:80
NameVirtualHost 192.168.1.70:443
NameVirtualHost 192.168.1.71:80
NameVirtualHost 192.168.1.71:443

The VirtualHost statements in Apache2/sites-available explicitly state the internal ip addresses as you recommended.

When I get Virtualmin to re-check configuration it states that the Default IP address for virtual servers is 192.168.1.65. How do I get Apache to send the other two domains on virtual ip's to their own public_html directories? Everything else seems fine:

The status of your system is being checked to ensure that all enabled features are available, that the mail server is properly configured, and that quotas are active ..

BIND DNS server is installed, and the system is configured to use it.

Mail server Postfix is installed and configured.

Apache is installed.

Webalizer is installed.

Apache is configured to host SSL websites.

MySQL is installed and running.

ProFTPd is installed.

Logrotate is installed.

SpamAssassin and Procmail are installed and configured for use.

ClamAV is installed and assumed to be running.

Plugin DAV Login is installed OK.

Plugin AWstats reporting is installed OK.

Plugin Mailman is installed OK.

Plugin Protected web directories is installed OK.

Using network interface eth0 for virtual IPs.

IPv6 addresses are available, using interface eth0.

Default IP address for virtual servers is 192.168.1.65.

Both user and group quotas are enabled for home and email directories.

All commands needed to create and restore backups are installed.

.. your system is ready for use by Virtualmin.

I hope you can shed some more light on this irritating problem.

Tue, 05/26/2009 - 09:02 (Reply to #9)
andreychek

Well, this sounds like a lingering "VirtualHost *" in there somewhere.

If you type:

grep -i '<virtualhost' /etc/apache2/sites-enabled/*

Can you verify that none of them have a * listed?

Also, you might consider restarting Apache, to make sure it's running with the latest configuration.
-Eric

Tue, 05/26/2009 - 09:06 (Reply to #10)
Joe
Joe's picture

<div class='quote'>I've checked the apache2-default file and removed any NameVirtualhost * and explicitly stated all the ip addresses I'm using as follows:

NameVirtualHost 192.168.1.65:80
NameVirtualHost 192.168.1.65:443
NameVirtualHost 192.168.1.70:80
NameVirtualHost 192.168.1.70:443
NameVirtualHost 192.168.1.71:80
NameVirtualHost 192.168.1.71:443

The VirtualHost statements in Apache2/sites-available explicitly state the internal ip addresses as you recommended.</div>

You've missed something. The cause of the problem is that one site is sucking up requests because it is the &quot;first best&quot; match for a particular IP:port combination. So you've either got problems with your public to private IP forwarding (so those non-default IP hosts are coming in on the wrong IP and the name is meaningless for that IP:port combo, so it falls through to the &quot;default&quot;) or you've still got some indeterminate IP:host combos in there (* or *:80) somewhere.

If you're sure you've corrected the * stuff, then check your routing. If there are multiple private IPs, you'll need as many public IPs forwarding to them, and they must be correct (e.g. DNS says public IP is x.x.x.x, so x.x.x.x much map to the private IP Apache thinks is right for that name) or you'll get exactly the behavior you describe.

--

Check out the forum guidelines!

Tue, 05/26/2009 - 14:20
justinwpw

Joe, thanks for that! Yes, it was the router problem. I only have one static external ip address at this location, so it looks like I will have to run SSL on one of the domains only (not a major problem for me, but could be to somebody else).

I have now deleted the other two domains on virtual ip's and created them again to share the same internal ip 192.168.1.65 (I understand that you need virtual ip's to run SSL on more than one domain).

All three domains now resolve correctly to their own public_html directories.

Now trying to install Joomla 1.5 in one of these directories and Joomla has detected that it does not have MySQL support! MySQL server is most definitely running. I found this link that seems to describe the problem:

http://www.virtualmin.com/forums/help-home-for-newbies/mysql-support-in-...

But, that's another problem...

Thanks.

Tue, 05/26/2009 - 14:33 (Reply to #12)
andreychek

Yeah make sure you have php5-mysql installed.

If you're still having troubles, create a PHP script, and have it run phpinfo() -- and use that to verify that the MySQL module is loading.

If things just aren't working, yell and we'll lend a hand. Help our sanity and start a new thread though :-)
-Eric

Topic locked