apache virtual hosts not working on fresh install of virutualmin ubuntu10.04

I set up ubuntu 10.04 on a virtual box(bridged adapter on a local network) and ran the "install.sh" script like I have before in the past. But for some reason the virtual hosts do not work. All Apache Virtual Hosts point to the default host whether I use virtualmin or if I set them up manually through apache and do the DNS through BIND. Why is this broken?

PS, I tried reinstalling it several times with the same problem.

Status: 
Closed (works as designed)

Comments

Howdy -- you may want to go into System Settings -> Re-check Config to make sure Virtualmin doesn't see a problem with your network settings.

There's some more complicated aspects of setup when dealing with a server on a local LAN behind a NAT router, than when directly on a public IP address. Running the Re-Check Config can detect some issues regarding that.

If that doesn't help -- the support tracker here is for Virtualmin Pro customers, it looks like you're using Virtualmin GPL. Virtualmin GPL users can use the forums to obtain support -- there's lots of wonderful folks who help out there, and we monitor that as well!

If you have additional questions, we'd encourage you to post your questions over there in the forums. Thanks!

thanks for the help. I tried that. the only thing that popped up was the warning about my local IP not matching the external IP. Correct me if I am wrong, but that should not affect how Apache works. My local domains were finding the server but, apache was not routing them to the correct directories. It kept defaulting to only one of the virtual hosts in apache.

I have reinstalled my system starting with traditional LAMP and installed virtualmin as a webmin module manually thought the webmin module install page. After the usuall issuer resolutions, it is working correctly. So I believe there is an issue with the install script. It would be nice if we could figure this out as I would prefer to use the install script as it is much easier.

Yup, that's exactly the issue I was thinking it would discover :-)

What you're running into is a common problem when dealing with NAT -- IP addresses aren't matching up properly, and Apache isn't sure which domain to show.

You'll want to follow the steps mentioned in the Re-Check Config -- making sure that in System Settings -> Virtualmin Configuration -> Network Settings, that things are setup properly there.

Also, if your server is on your local network, and your using a computer on your local network to access it -- that can cause problems too unless your router supports such a setup.

The installation script is working as expected though :-)

When you say they are pointing to the "default host", what do you mean exactly? Are you getting the content for your first domain for all domains, or some generic page?

Ok, I went to System Settings -> Virtualmin Configuration -> Network Settings and I don't see anything wrong. Default IP is derived from "From network interface" (eth0). DNS record IP is derived from Default IP.

Here is the warning I get when I recheck the virtualmin config, note( I have hidden the external ip for security reasons) "Default IP address is set to 192.168.1.100, but the detected external address is actually xx.xx.xxx.xx. This is typically the result of being behind a NAT firewall, and should be corrected on the module configuration page."

I got my router and my pc configured for the bind DNS server. Thats cake here.

Starting out, my default server loads the "Its Works...etc" page. When I create the first virtual server, both it and the default server load the "Forbidden..etc" page. Then I manually changed the "address" setting of the new virtual server in Apache from the IP ( the correct IP by the way) to "any" and then they both load the default server page that says "It Works"(var/www). Then I changed the address field of the virtual server from "any" to the domain name and both it and the default server then load the virtual server path. Then I manually created another virtual host in apache and manually created the DNS in BIND. Finally all 3 servers load the same page. Then I gave up.

So yes all virtual servers are loading the same path on the server and the are set to "Forbidden". If there is a setting I can change to make this go away and it will fix my Apache then just tell me what to do.

So I see a few possible issues here :

  1. I would recommend undoing any manual changes you made to the Apache config, as Apache is very sensitive to the correct use of IPs for virtual hosts.

  2. If you are behind a NAT device, make sure that the domain's IP is set to 192.168.something as shown at Server Configuration -> Change IP Address. The external IP should be used at Edit Virtual Server -> Configurable settings -> External IP address.

  3. If you are getting a forbidden error message, make sure that the domain's public_html directory contains an index.html , index.htm or index.php file. By default, the contents of the directory will not be listed..

I took your steps and even though they had no effect I seem to have discovered the real issue. Actually, for no apparent reason, I am no longer getting the warning about the external IP even before I took these steps.

  1. I have reinstalled several time since my first attempt when I played with Apache manually. Currently for testing, everything is being administered though Virtualmin.

2.Yes the Domain IP is set to the local 192.168.1.100. Setting the domains external IP to my external IP had no effect.

3, Yes indeed, adding the index page did eliminate the "Forbidden" page but still the Default server loads the first virtualmin server or actually the first virtualmin server becomes the default server. ( I am talking about what the Host Name loads as the Default Server)

So in conclusion, I created a 2nd virtualmin server and found that it did load separately from the first virtualmin server. So I guess the real issue is that the Apache Default server becomes non-active when the first virtualmin server is created and the first first virtualmin server becomes the Default Server. This was confusing me. So the final solution to this thread is to remember that when using the install script, I have to recreate the default server in virtualmin.

I think in past I may ran into this and figured it out quickly but today I just decided to waist your time.

thanks,

Joe's picture
Submitted by Joe on Sun, 09/25/2011 - 02:58 Pro Licensee

This is expected behavior from Apache. Apache has two modes of operation, either one site (the "default" website, where domain names do not matter), or virtual hosting with multiple name-based sites. Has nothing to do with Virtualmin...it's how Apache works. When you create name-based virtual hosts (which is all Virtualmin is designed to work with), there is no longer any such thing as a "default" website. Apache will go through a decision tree to decide which site to display, when a perfect match is not found, and without a pretty deep understanding of how Apache works and makes that decision, it appears to be undefined or unpredictable behavior.

The solution is to stop imagining "default" site has any meaning in a virtual hosting environment. Create all of your websites as virtual hosts. This applies whether Virtualmin is involved or not.

Maybe you never noticed, but the first entry in the virtual hosts of apache takes on the default host role of apache. that means that any domain or ip pointing at the server that is not claimed by a virtual host will fall on the first virtual host by default which is the whole reason for having a default host unless you set up the server to direct unclaimed traffic in another specific way. Which is what you would do anyways if you were planning to use your server for commercial use.

So my point is that it is confusing to have the first virtualmin host over ride the apache default host with out telling me. so imagine I set up a server and create the first virtual host not realizing it is acting as the default host catching unwanted domains and ips creating duplicate content on the web. Or in my case I become alarmed when the default host file in the sites_enabled directory no longer functions leading me to think something is not working correctly.

If you set up virtualmin as a module instead of using the install.sh script, you will find that it does not behave this way and the default host file set up by apache continues to function.