Link to home
Start Free TrialLog in
Avatar of Softverkpro
Softverkpro

asked on

Sharing port 80 between IIS and Tomcan server on the same machine

hi, here is the situation:

we have two subdomains pointing to the same computer  (windows server 2008) and we are running IIS as webserver on one domain and Tomcat as webserver on another domain.  this is what we have now:

domain1.mycompany.com , ip 1.2.3.4 , IIS on port 80
domain2.mycompany.com , ip 1.2.3.4 , Tomcat on port 81

But it has become necessary to run both of them on port 80 and do routing based on the request (i guess by looking at the domain) .

How can i set this up in IIS and Tomcat? can anyone help ?

How can i
Avatar of Adrian Cantrill
Adrian Cantrill
Flag of Australia image

Its not possible (AFAIK) to have two services running on the same port/same IP in this way. Have you not considered adding another IP address to the NIC of the machine, and pointing each of the domains to separate IP's. That way you can have tomcat bound to 1.2.3.4:80 and iis bound to 1.2.3.5:80..

I know its not what you asked, but what scenario would you need two webservers on the same IP /port?
I suspect this will not work.  Is there a reason you cannot use two separate IP addresses?
You will need to add another IP to the NIC on this server ie 1.2.3.5 - you can do this in network connections from control panel, TCP/IP settings, advanced button.

once you have done this you need to bind IIS to one IP and Tomcat to the other (both port 80)

to bind IIS right click my comp, manage, services and apps, IIS, Web sites, right click web site and properties, choose IP address.

Not sure how to bind tomcat but it will be in one of the settings files (maybe server.xml) in the conf folder no doubt.

update your DNS to point domain1 to 1.2.3.4 and domain2 to 1.2.3.5
(you beat me too it woolnoir)
You propably want ot have a tomcat application served on the same domain or IP without needing clients to enter the specific port in their URL.
E.g.
http://www.yourdomain.com/    should give a website
http://www.yourdomain.com/application     should give a the tomcat application

And you do not like to have the application as
http://www.yourdomain.com:PORT/application

Let IIS route all request to http://www.yourdomain.com/application through internally to the tomcat server, which runs on another port. Configure IIS as a proxy for the tomcat server, which runs on the same machine but internally on another port. This port needs only be bind to localhost.

Regards,

Oli

ASKER CERTIFIED SOLUTION
Avatar of samri
samri
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial