Connect to VM localhost virtual directory

localhostvirtual machinevirtualbox

I have an Ubuntu guest VM operating inside Windows 7 host (VirtualBox with Bridged Networking enabled). In my VM, instead of browsing to http://localhost/somesite I set up virtual directories in apache to point to http://somesite. This is fine for when I'm working within Ubuntu, but I need to try to connect to the site from my Windows 7 host. If I enter in my browser address bar, I do indeed see the apache welcome page, but how can I browse to my Virtual Directory/Site?

Best Answer

I don't know the Virtual Directory/Site feature, but if it is similar to the Virtual Hosts feature in WebSphere, setting up a hostname "somesite" with IP in the Windows hosts file (default: C:\Windows\System32\drivers\etc\hosts) should work.

The entry would just look like this: somesite

Please note that you need Administrator rights to edit this file in Windows 7. Easiest solution might be to open Notepad with those rights (right click -> run as Administrator) and then open the file from that editor.

Basically you need to instruct your browser to use that hostname for the Host field in the HTTP request (that is sent to the IP after resolving the hostname anyway) like this:

GET / HTTP/1.1
Host: somesite