How to configure a Web Server within VirtualBox

The point of the project was this, create a web server using VirtualBox and host it on a Windows 7 64-bit platform. And why would I do something odd? Well, I need a copy of Windows 2003 Server Web Edition running on a new platform since the physical PC it was running on literally tore itself to pieces. The drives failed and the cost of buying EIDE drives is just a waste of money.

So why not just upgrade? Well, I will in the future, but I was actually using that machine. I’m familiar with 2003 and had everything dialed in the way I like it. And why host it in Windows 7? That’s the host OS of my most powerful machine, a 6-core machine with 16GB of ram. No sense in rebuilding everything when Windows 2003 Server isn’t multicore aware and only accesses 4GB of ram. But anyway, the OS and the host are sort of irrelevant, it’s the configuration that’s important. So here’s what I did.

First, within VirtualBox, change the networking from NAT to BRIDGED ADAPTER. Select the physical network adapter you want your host machine to connect to. If you have more than one network card, pick which one you want the Guest OS using. My machine has both wired and wireless NICs. I set VirtualBox up on the Wireless NIC.

image

Second, pick the Virtual network card you want the guest OS to emulate. I chose the Intel Pro/1000 MT.

Third, boot the Guest OS and change the IP address of the virtual machine to the same IP address as your internal network. By default VirtualBox using 192.168.56.1. You Guest machine will probably have a similar address. Change it over to the same IP range as the guest machine, something like 192.168.1.xxx. For example, my host is 192.168.1.100 so the guest is 192.168.1.101. You need to give it a static IP address so you can set the Port Forwarding on your Router.

image

Fouth, set Port forwarding on your router. Send traffic destined for port 80, 21 and whatever else you like (such as RDP) to the internal address of the Guest machine. Again, if the Guest is 192.168.1.101 then forward the traffic to that address. DON’T send anything to the VirtualBox network address of 192.168.56.xxx.

image

Finally, make sure to DISABLE all POWER MANAGEMENT functions of both the HOST and GUEST OS. And not just for the machine and hard drives. Make sure you turn it off for the Network Cards. Your Server OS probably doesn’t have anything, but the Host might. My Windows 7 machine had Power Management turned on for both NICS. Disable that or your web server won’t get any traffic. For Windows 7 – Control Panel – Power Options – Change When the Computer Sleeps.

For the network card, Control Panel – Network and Internet – View Network Status and Tasks – Change Adapter Settings – Pick the BRIDGED ADAPTER you selected in VirtualBox, Right Click and choose Properties – Click Configure for the networking device itself. Click the Power Management tab to turn off any power saving options.

image

image 

That should be it. I now have Windows Server 2003 on the live web and it loads PHP, HTML and ASPX pages just fine. In fact, it’s faster than it ever was on the old hardware. Now I can load Windows Server 2008, configure it within it’s own VirtualBox, load all the correct modules and make the switch when I’m ready. Plus, I can have a standby server by making a copy of the VHD files.

This is specific to Windows 7 and Server 2003, but the concept is the same. You need to configure a BRIDGED APAPTER and configure a STATIC IP ADDRESS in the Guest OS. From there, you should have it all set.

Other articles of interest:

2 Responses to How to configure a Web Server within VirtualBox

  • venkat says:

    Hi,

    I had set up windows server 2003 in my windows 7 with bridge network connection. I have used dnsafraid to configure my ip. The problem i am facing is that when i hit my domain name say http://www.abc.com on the browser the page that is being displayed is my router entry page http://192.168.1.1/ and it prompts for username and password. I had also configured nat – virtual server in my router page as follows. NAT — Virtual Servers Setup as follows. Pls help me with this issue. The ip of my windows server within the lan is set to 192.168.1.4. Can u help me find out the mistake i am doing while configuring i have been trying for about a week. pls help me.

    Virtual Server allows you to direct incoming traffic from WAN side (identified by Protocol and External port) to the Internal server with private IP address on the LAN side. The Internal port is required only if the external port needs to be converted to a different port number used by the server on the LAN side. A maximum 32 entries can be configured.

    Server Name External Port Start External Port End Protocol Internal Port Start Internal Port End Server IP Address Remove
    Webserver2003 80 80 TCP/UDP 80 80 192.168.1.4

    • Don Pedro says:

      It sounds like the port forwarding isn’t set up correctly on the router itself. You’re making it to the inside network but the traffic isn’t being sent to VirtualBox. There should be something in the router that sends your HTTP traffic to the correct IP address of your Virtual Machine.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments