Reputation: 11549
I have an Apache Tomcat which is running on a Windows Server 2008 R2 Standard and hosting a web site (www.domain1.com). Apache is currently listening port 80 on the server. Now, on the same server I want to host a Http server application written in .NET (www.domain2.com) which will be running as a Windows service. I also want Http server to be accessed as www.domain2.com via port 80.
So simply I need is.
Request Forward To
1. http://www.domain1.com/[anything] http://localhost:8080/app1/[anything] <-- tomcat
2. http://www.domain2.com/[anything] http://localhost:8000/[anything] <-- windows service
I tried to use below netsh configuration but it did not help.
netsh interface portproxy add v4tov4 listenport=80 listenaddress=www.domain1.com connectport=8080 connectaddress=127.0.0.1 protocol=tcp
netsh interface portproxy add v4tov4 listenport=80 listenaddress=www.domain2.com connectport=8000 connectaddress=127.0.0.1 protocol=tcp
When I checked telnet localhost 80
from local machine or telnet www.domain1.com 80
from a remote machine it is not connecting.
I am open to any port forwarding solution that involve netsh, IIS, Tomcat or any other third party tool to achieve my goal.
Following Carlos' recommendations below configuration worked
-
<system.webServer>
<rewrite>
<rules>
<rule name="forward domain1 to tomcat">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="domain1.com" />
</conditions>
<action type="Rewrite" url="http://localhost:8080/app1/{R:1}" />
</rule>
<rule name="forward domain2 to windows service">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="domain2.com" />
</conditions>
<action type="Rewrite" url="http://localhost:8000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Upvotes: 2
Views: 4656
Reputation: 13581
A couple of recommnedations:
Upvotes: 2