>

This article introduces the method to access the web server resides in Guest OS behind Virtualbox From Host’s Browser (Windows).

As we known, access to the web server behind Virtualbox in Bridge Mode is pretty straightforward and easily setup, however, there are a lot of disadvantages
when we use Bridge Mode to communicate between Host OS and Guest OS running on Virtualbox. For example, ip conflicts, in some environment (eg. in
a company internal network), dhcp is not allowed to lease a ip to a strange device (the guest OS on Virtualbox is one), and manually configure static ip will cause ip conflicts with other ips that have already be assgined, and therefore Guest OS is not able to access to the internet. In summary, Bridge Mode makes things non-trivial and cause inconveniences/problems quite often.

Instead, NAT Mode is easy to use in such circumstances, and get us away from the problems stated above. I will demonstrate the way to access the web server on Guest OS running on VirtualBox from Windows Host Browser(Chrome, Firefox, etc).

Essentialy, the technique that will be used are Port forwarding and SSH tunneling (Socks proxy).

  1. Set up VirtualBox network adapter as NAT and configure a port forwarding rule on VirtualBox so that we can ssh into the Guest OS:

  1. Set up a ssh tunnel between Host OS and Guest OS, this is by setting up a local socks proxy server on Host OS (Windows), and then point the web browser to connect to this server, what this socks proxy server located on Host OS do is listen on the specified local port and forwarding all the packages to the destination (the Guest OS). By this, we are able to browse the web pages on Host OS.

Specifically, we can use putty as a ssh client to set up a socks proxy server on Windows:

select Dynamic, and enter a port number, e.g 2048 in Source port inputbox, press Add

Go back to Session window, fill in Host name and port like below, press Open

Now, a ssh tunneling should be set up successfully!

We can go to Windows command line and type: netstat -n -a

As is shown the port 2048 is on LISTENING. This means anything that connects to 127.0.0.1:2048 will go through the ssh tunnel to reach the destination (Guest OS).

  1. Configure the browsers(Firefox, Chrome, etc.) to use Socks proxy:
  1. Use Guest’s Internal IP address as the ip address that our browser connects to.
    For example, we have set up a web server in Guest OS, and the web page on Guest OS should be look like: http://localhost:80
    here we want to access this http page on the Host OS’s browser, the actual address we will use should be http://10.0.2.15:80 in broswer on Host OS.

Or
If we set up a Host-Only adapter also, we can use host-only ip address as well.
For example, the host-only ip address of the Guest OS is 192.168.56.121

then we can access the page of Guest OS from Host’s browser like this:

Extra Knowledge

View Hadoop job status and history page in Windows Browser

We need to start Map Reduce Job History Server before we can view the job status on web pages:

$ $HADOOP_HOME/sbin/mr-jobhistory-daemon.sh start historyserver

or

$ $HADOOP_HOME/sbin/mr-jobhistory-daemon.sh --config $HADOOP_CONF_DIR start historyserver

then check whether historyserver has started successfully:

$ jps

If we do not start job historyserver, we won’t be able to connect to 19888 prot, and we will probably see error messages like this:

Even in Guest OS itself:

$ netstat -ntlp | grep 19888
(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:19888 0.0.0.0:* LISTEN 3176/java

after historyserver is started successfully, we should be able to see the page like this:

参考:
Not able to see Job History(http://localhost:19888) page in web browser in Hadoop

http://serverfault.com/questions/136715/how-do-i-access-a-web-server-on-a-virtualbox-from-the-host-machine
http://tuxtweaks.com/2010/03/access-your-web-server-from-virtualbox/