Wednesday October 15, 2008 |
Using a Virtual Box serviceI 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 What next, snipsnap? tags: technology software virtualbox networking guest proxy (2008-10-15 15:08:36.0) Permalink Comments [1] Post a Comment: Comments are closed for this entry. |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 #