HTTP port forwarding

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
brunns
Posts: 4
Joined: 26. Jun 2009, 18:13
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: Ubuntu

HTTP port forwarding

Post by brunns »

In trying to set up HTTP port forwarding on my Mac, and something's stopping my host system from seeing my guest. The extra data for my VM looks like so:

Code: Select all

dawkins:~ simon$ VBoxManage getextradata charles1 enumerate
(snip)
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort, Value: 2222
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort, Value: 22
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol, Value: TCP
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/django/HostPort, Value: 8889
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/django/GuestPort, Value: 8080
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/django/Protocol, Value: TCP
Funny thing is, SSH is working fine over port 2222, but I my host gets nothing over HTTP. I can conform that the server is running on the guest - "curl http://127.0.0.1:8080/" there returns a bunch of HTML as I'd expect. But running "curl http://localhost:8889/" from the host returns "curl: (52) Empty reply from server".

I'm sure I'm doing something stupid, but I'm too stupid to work out what it is. Any pointers would be much appreciated.

My host is a Mac running VirtualBox 2.2.4 on OS X 10.5.7, my guest is running Ubuntu 9.04.

Cheers,
Simon B.
Last edited by brunns on 28. Jun 2009, 13:34, edited 1 time in total.
brunns
Posts: 4
Joined: 26. Jun 2009, 18:13
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: Ubuntu

Re: HTTP port forwarding

Post by brunns »

Does any of this give any clues?

On the host:

Code: Select all

dawkins:~ simon$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 00:19:e3:36:76:16 
	media: autoselect status: inactive
	supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex,flow-control> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none
fw0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 2030
	lladdr 00:19:e3:ff:fe:83:e5:70 
	media: autoselect <full-duplex> status: inactive
	supported media: autoselect <full-duplex>
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	inet6 fe80::219:e3ff:fed8:7c9%en1 prefixlen 64 scopeid 0x6 
	inet 192.168.1.121 netmask 0xffffff00 broadcast 192.168.1.255
	ether 00:19:e3:d8:07:c9 
	media: autoselect status: active
	supported media: autoselect
en2: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
	ether 00:1c:42:00:00:00 
	media: <unknown type>
	supported media: autoselect
en3: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
	ether 00:1c:42:00:00:01 
	media: <unknown type>
	supported media: autoselect
vboxnet0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 00:76:62:00:00:00 
dawkins:~ simon$ netstat -na | grep 2222
tcp4       0      0  127.0.0.1.2222         127.0.0.1.51787        ESTABLISHED
tcp4       0      0  127.0.0.1.51787        127.0.0.1.2222         ESTABLISHED
tcp4       0      0  *.2222                 *.*                    LISTEN
dawkins:~ simon$ netstat -na | grep 8889
tcp4       0      0  *.8889                 *.*                    LISTEN
On the guest:

Code: Select all

oliver@charles1:~$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:a7:b5:9e  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea7:b59e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:605 errors:0 dropped:0 overruns:0 frame:0
          TX packets:480 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:52530 (52.5 KB)  TX bytes:61810 (61.8 KB)
          Interrupt:11 Base address:0xc020 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:10600 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10600 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5400985 (5.4 MB)  TX bytes:5400985 (5.4 MB)
I'm running the VM using VBoxHeadless. The Ubuntu server is a pretty minimal install; I took Ubuntu's Minimal Virtual Machine option, and just added what I needed - Django and its requirements, basically, plus emacs, SSH, curl and a few other bits and bobs.

Any ideas? It *really* looks like it should be working.

Cheers,
Simon B.
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: HTTP port forwarding

Post by baf »

Please cut and paste the results of these two.
what does netstat -na |grep 8080 in the guest show?
and netstat -na |grep 8889 on the host (with the guest running respectively shut down)?
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
brunns
Posts: 4
Joined: 26. Jun 2009, 18:13
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: Ubuntu

Re: HTTP port forwarding

Post by brunns »

Thanks for the help, baf.

On the guest:

Code: Select all

oliver@charles1:~/charles1/share/warts$ netstat -na | grep 8080
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8080          127.0.0.1:45971         TIME_WAIT  
On the host with the guest running:

Code: Select all

dawkins:~ simon$ netstat -na | grep 8889
tcp4       0      0  *.8889                 *.*                    LISTEN
On the host with the guest shut down:

Code: Select all

dawkins:~ simon$ netstat -na | grep 8889
That last is not a cut 'n' paste error - there's no output.
baf
Volunteer
Posts: 829
Joined: 27. Sep 2008, 06:18
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: linux,xp,win7
Location: Luleå or Skellefteå, Sweden

Re: HTTP port forwarding

Post by baf »

Bingo! this
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
Means that your process only listens on the localhost interface and not the "real" one

It must look like
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
or possibly
tcp 0 0 "real ip":8080 0.0.0.0:* LISTEN
for this to work.

So this is a configuration problem with whatever you run as webserver. Django? or whatever.
Tell us what that is first and well see.
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
brunns
Posts: 4
Joined: 26. Jun 2009, 18:13
Primary OS: Mac OS X Leopard
VBox Version: PUEL
Guest OSses: Ubuntu

Re: HTTP port forwarding

Post by brunns »

Thanks, baf, you're a star!

I was running a Django development server. Your pointer lead me to Django Development in VirtualBox, and thence to the Django runserver docs. Turns out I have to start up my server on ip 0.0.0.0, and all is well.

Code: Select all

python manage.py runserver 0:8080
Don't think I'd ever have got there without you. Thanks again.
Post Reply