Virtual box localhost access

networkingvirtual-machinesvirtualboxvirtualhost

Question on Virtual Box 4.1.8
So, i have Ubuntu 10.10 as host machine and Windows Xp as guest machine.
On host machine there is tomcat with web app running on port 8888.
When i am in guest machine i type in browser:

http://10.0.2.2:8888/Something.html and it works.
But my Something.html has links to javascript like src="http://localhost:8888/webApp/someScript.js and they obviously aren't working(because of "localhost" part).
The other problem is that i don't want to use relative path now, only absolute. Also i don't want to change localhost to Host Ip in my links
Maybe there is some solution, like port forwarding or network config of Virtual box, that i can type in my guest browser
http://localhost:8888/Something.html

Thanks for any clues.

Best Answer

Your real problem is that you want to do things that doesn't make sense for any kind of web app that should serve anything outside it's machine: You need links that work without tricks on the client machine, either with relative paths where applicable or non-local hostnames.

Of course there is a workaround:

Simply install Putty on Windows and use it to create a port forwarding from port 8888 on your machine to port 8888 on 10.0.2.2. You will find lots of links with Google that explains how this is done in Putty.

Afterwards, you can simply connect to localhost:8888 and stuff should work.