I have a Windows 7 host machine running VirtualBox (v4.122) and a guest VM of Kubuntu 12.04 running Apache2.

I can access the Apache server from the host machine but it will only load the default Apache welcome page and is ignoring all of my virtual hosts.

Some more details about the configuration:

  • The Kubuntu VM has several virtual hosts that all work fine when accessed via a web browser inside the VM.
  • I am using port forwarding in VirtualBox to send port 8080 on the host machine to port 80 on the guest.
  • Both /etc/hosts in Kubuntu and C:\Windows\System32\drivers\etc\hosts have the entries for the local domains and are set to resolve to
  • Accessing 'localhost' on the Kubuntu machine will resolve to the directory set in the default vhost (/var/www/) but accessing localhost:8080 servers up the default web page for the server (i.e. "It works ...")

Updated to add output from apache2ctl -S:

     VirtualHost configuration:  is a NameVirtualHost
     default server dghportal.local (/etc/apache2/sites-enabled/dghportal.local:1)
     port 80 namevhost dghportal.local (/etc/apache2/sites-enabled/dghportal.local:1)
     port 80 namevhost local.classtoolkit.org (/etc/apache2/sites-enabled         /local.classtoolkit.org:1)
     wildcard NameVirtualHosts and _default_ servers:
     *:80 is a NameVirtualHost
     default server itechsrv-kuvm1 (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost itechsrv-kuvm1 (/etc/apache2/sites-enabled/000-default:1)
     Syntax OK
  • Can you provide the output of apache2ctl -S? – Shane Madden Oct 24 '12 at 23:45
  • thanks, Shane -- I've updated the original post with the output – Alex Oct 24 '12 at 23:51

Looks like your custom <VirtualHost> blocks are configured as <VirtualHost> - this won't ever catch requests from a different host.

The requests from the other device are being caught by the vhost defined at /etc/apache2/sites-enabled/000-default:1 - this is what's causing the welcome page to appear.

Change your vhost definitions from <VirtualHost> to <VirtualHost *:80>, and you should be all set! You might also want to a2dissite default, so that your sites, not the welcome site, can catch requests to a hostname that doesn't match one of the ones that's already configured.

  • Thanks a lot -- I had named the URL in the VirtualHost block (which is what was causing it to resolve to but I replaced it with the wildcard and access from the host machine is working now. – Alex Oct 25 '12 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.