Testing web application with Internet Explorer via virtual machine and port forwarding

Hacks Web Design
Create tunnel from Windows machine into your Mac

Create tunnel from Windows machine into your Mac

For all of you front-end developers out there, this could be a rare but very good find. It saved me time when working on styling of a web application and I am sharing it with you here today.

How many times have you thought about seamlessly testing an application you run on the localhost under Windows’ most favorite browser – Internet Explorer? While many of you test by running virtual machine and pointing browser to the host Mac’s IP (e.g. 10.0.2.2) to load the page, sometimes the application running on the host does something (in my case SSO – Single Site Sign-on) that redirects you back precisely to localhost server name only. In addition, your front-end application might use REST endpoint running on the same machine under a different port. To address this, we are going to create a tunnel between Windows virtual machine and your host Mac, so that Internet Explorer would feel “integrated” into Mac OS.

In my case, I have two host machine ports I want to forward – 8080 (Java backend app is running there) and 9000 (Grunt is running my server on it), so I am going to open Windows Run prompt (make sure you “run it under Administrator”) and issue the following commands:

netsh interface portproxy add v4tov4 listenport=8080 listenaddress=10.0.2.15 connectport=8080 connectaddress=10.0.2.2

and

netsh interface portproxy add v4tov4 listenport=9000 listenaddress=10.0.2.15 connectport=9000 connectaddress=10.0.2.2

Note, 10.0.2.15 is the IP of Windows virtual machine (you can get it by running “ipconfig” command) and 10.0.2.2 is the Mac (host) gateway address. Now, if you open your Internet Explorer and go to http://localhost:9000 or http://localhost:8080 you will see your application responding just like it does on the Mac OS.

A few commands you might find handy:

netsh interface portproxy show all

to make sure, you did forwarding correctly and

netsh interface portproxy reset all

to bring things back to how they were.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.