One of the objectives of my virtualisation experiments, was to use the ‘Express’ guest as a ‘server’, i.e. to enable apps running on the host to access ‘Express’ applications running in the guest. For example, to make OFA running in the guest accessible to a browser, for example Firefox, running on the host. Once this is achieved it should be possible to make this available to a wider network.
Reading the VirtualBox documentation, this should be easily achievable, and indeed it proves to be pretty straightforward. The default networking mode for VirtualBox is NAT, or Network Address Translation. In a normal configuration this simply means that any network connection on the host, for example an internet connection, is transparently available to the guest. Thus the guest machine can connect directly to the internet without having to set anything extra up.
A feature of the NAT implementation in VirtualBox, is ‘Port Forwarding’. To quote from the help system :
….As the virtual machine is connected to a private network internal to VirtualBox and invisible to the host, network services on the guest are not accessible to the host machine or to other computers on the same network. However, VirtualBox can make given services available outside of the guest by using port forwarding…..
This sounds to be exactly what I want. The help system then goes on to give an example of the required syntax. My configuration is a Linux host, Ubuntu, and a Windows XP Pro guest. So the examples I am going to give as based on that configuration, it may be slightly different for a Windows host.
Firstly the basic syntax, there are 3 commands that need to be issued :
VBoxManage setextradata “name-of-VM“
“VBoxInternal/Devices/type-network-card/network-interface-number/LUN#0/Config/name-of-service/Protocol” protocol
VBoxManage setextradata “name-of-VM“
“VBoxInternal/Devices/type-network-card/network-interface-number/LUN#0/Config/name-of-service/GuestPort” guest-port-number
VBoxManage setextradata “name-of-VM“
“VboxInternal/Devices/type-network-card/network-interface-number/LUN#0/Config/name-of-service/HostPort” host-port-number
Where :
name-of-VM is the name of the VM as displayed in VirtualBox setting in the ‘General’ section.
type-network-card is the type of network card as shown in the VirtualBox settings ‘Network’ section. This is usually ‘pcnet’, the default used by VirtualBox, unless you have changed this.
network-interface-number is the network card number (counting from 0). Usually this is 0, unless you have configured multiple virtual network cards on your VM.
name-of-service is any name you wish to give to the service you are setting up for port forwarding.
protocol is either ‘TCP’ or ‘UDP’.
guest-port-number is the port number on the guest that you wish to have traffic forwarded to from the host.
host-port-number is the port number on the host that you wish to forward to the guest.
This looks a bit intimidating, but I’ll work through it using my VM as an example. Firstly I need to gather the information required to complete the options described above:
name-of-VM My VM is called ‘WinXPOESOFAOSA_baseline’.
type-network-card is the default ‘pcnet’.
network-interface-number I only have one configured virtual network card so this is the default, 0
name-of-service I called this ‘guestexpress’.
protocol is TCP.
guest-port-number My guest is running Apache to enable the web services for Express Web Agent, OFA web and OSA web. It is configured to listen on the default port 80, so that is the guest-port-number.
host-port-number According to the VirtualBox help, Unix and Unix like OSs (Linux & MacOS), cannot forward traffic for IP addresses lower than 1024 from applications that are not running as root. Therefore to avoid problems I set this to 8080.
So my commands looked like this :
VBoxManage setextradata “WinXPOESOFAOSA_baseline” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestexpress/Protocol” TCP
VBoxManage setextradata “WinXPOESOFAOSA_baseline” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestexpress/GuestPort” 80
VBoxManage setextradata “WinXPOESOFAOSA_baseline” “VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestexpress/HostPort” 8080
These were entered in a Linux console window. For Windows enter the commands in a cmd.exe window. Before entering the command ensure that the guest OS is completely shutdown (not paused), and close VirtualBox. The settings will take effect next time VirtualBox and the VM are started.
After re-starting my VM I opened Firefox in the host and entered the address ‘http://localhost:8080’, this should be forwarded to the guest port 80, and return the default Apache page, which on my guest simply throws out the message ‘It Works!’, and here it is, in both the guest and host :

Default Apache page in guest VM and host
Now to get the Express web apps working. The Express Web Agent (EWA) samples worked without issue. However OFA web did not. Comparing the EWA sample ‘index.html’ page with the standard OFA ‘index.html’ page soon showed the answer. Here are relevant snippets from each :
From EWA :
TD WIDTH=296><a href=”/oowa-bin/oowa.exe/ExpSrv634/dbxwdevkit/xwd_init?samples/xs_start/required”>
Locally install Express Web Agent files and run Samples</a>:
Download the Express Web Agent Java classes to your local machine once.
From OFA :
var language = navigator.browserLanguage;
var win = window.open( “http://localhost:80/oowa-bin/oowa.exe/ExpSrv634/dbxwdevkit/xwd_init?%27ofaserve.db%27/ofa.ext.init.web/C:%2fofasystems%2fbaseline%2fshared%2f/YES/YES/”+language, ofaName, “toolbar=no,menubar=no,status=yes,height=screen.height,resizable=yes,width=screen.width”);
The OFA index.html file contains a hard coded HTTP address to the server and port number. So I simply removed this :
var language = navigator.browserLanguage;
var win = window.open( “/oowa-bin/oowa.exe/ExpSrv634/dbxwdevkit/xwd_init?%27ofaserve.db%27/ofa.ext.init.web/C:%2fofasystems%2fbaseline%2fshared%2f/YES/YES/”+language, ofaName, “toolbar=no,menubar=no,status=yes,height=screen.height,resizable=yes,width=screen.width”);
This now works fine in both the guest and host, as shown :

OFA Web main page in guest VM and host browser