Browse Web Site With IP Address Rather than localhost

Go to your IISExpress>Config folder, locate applicationhost.config. Change <bindings> as below:

<bindings>
      <binding protocol="http" bindingInformation="*:1407:YOUR_IP_ADDRESS" />
</bindings>

Before you do this , you will have to register this IP address using netsh command as below:

Port forwarding in Windows 7

If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.11:1234 with whatever IP and port you are using:

> netsh http add urlacl url=http://192.168.1.11:1234/ user=everyone

This just tells http.sys that it’s ok to talk to this url.

IMPORTANT: The user=everyone parameter must be specified according to the system language. So if your windows language is spanish the parameter must be user=todos.

> netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=1234 profile=private remoteip=localsubnet action=allow

This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.More information at this link.

Port forwarding Mac OS X

Step 1: View Current Firewall Rules

sudo ipfw show

Step 2: Add Port Forwarding Rule (80 to 8080)

The default port that Tomcat runs on is 8080, so here we show the command to do port fowarding from port 80 to 8080 (Tomcat’s default port). Obviously, this works for other ports as well, and you’d just have to adjust the command accordingly.

sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to any 80 in

This is a temporary change, and it will revert once you reboot. If you want to make it permanent, you can create a lauch deamon for it.

Optional Remove Rule

If you want to remove your firewall rules run:

sudo ipfw flush

Port Forwarding Using PFCTL (aka PF) on Mac OS X

The setup for pfctl is similar to ipfw. Github user kujon has created a nice guide to show how to set up port forwarding from port 80 to another port using pfctl.

Note: Be sure to change the bindings of your project only by locating its name. You can even keep the localhost binding and add a new one , this way you can access same webpage using both the given IP address and your old localhost binding.

Leave a Comment