« Madrid | Main | Holland »

20081015 Wednesday October 15, 2008

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:

              

(2008-10-15 15:08:36.0) Permalink Comments [1]

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 09:39 PM PDT #

Post a Comment:

Comments are closed for this entry.
Innovate on OpenSolaris
   in London

  Subscribe to this blog XML

  Now referenced at is.gd,
    http://is.gd/1BW3h

  AddThis Feed Button

  

  See my delicious tag cloud, or
  follow it using a feed reader.

  Also my sun mediacaster page

  Link to my FOAF file

News
Recent & Interesting
All about my site
Recently at del.icio.us
links
Article Index
archives

  2009

  2008

  2007

  2006

  2005

  2004

Blogosphere

Locations of visitors to this page >
referers