« Madrid | Main | Holland »

Using a Virtual Box service

I want to run a web service inside a Virtual Box container and consume it from initially the host OS, but later from other systems. This article describes how I accessed an apache served page from and Ubuntu 8 VM.

Using Virtual Box 2.0.2, I read the manual version 2.0.2 chapter 6.4 which talks about allowing the host to utilise port services on a guest. I have a windows host, and a Ubuntu Linux guest.

Despite the problems I have with the IT provided build, fortunately I have cygwin on the machine and so have an easy to use scripting language. Most importantly I have a rigourius 'cd' command with directory completion, my tcl and python shells are a lot fussier about the windows xp 16/32 bit name translation. So in the folder containing the program VBoxManage.exe, I create a script containing the following code,

# need to force the shell, wonder how you do that

USAGE="$0 [make | [rm|remove] | help ]"

case $1 in
make)   echo $0 make proxy
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/Protocol" TCP
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/GuestPort" 80
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/HostPort" 80
         ;;
rm|remove) echo $0 remove proxy
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/Protocol"
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/GuestPort"
        ./VBoxManage.exe setextradata "Ubuntu 8" \\
                "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache2/HostPort"
        ;;
help)   echo $USAGE ;;
esac

exit

I run the script with the argument 'make'. The token "Ubuntu 8" agrees with the VM name, and the token apache2 is afaik, anything I want so long as it agrees. Having run the script, I can boot Firefox in the host OS instance and see the guests default web page, using the URL http://127.0.0.1. Oddly, http://localhost is resolved as something else, but I expect its the apache configuration file that does this.

What next, snipsnap?

tags:

« Madrid | Main | Holland »
Comments:

I edited the original article to try and make its purpose clearer and narrative stronger. I also wonder if the use of cygwin another proof point that I should move on from windows as my laptop OS.

Posted by David Levy on October 15, 2008 at 02:39 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

DaveLevy

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today