Any one have an idea to share running multiple tomcats on single machine with same port 8080
Asked
Active
Viewed 3,899 times
5
-
2What problem are you trying to solve? – X-Istence Mar 21 '12 at 04:40
-
I want to run 2 websites on mcahine with same port 8080. If I shutdown one server that should not affect the other server. – Alzzz Mar 21 '12 at 07:04
4 Answers
4
One way would be to set up a single web server (such as Apache, but your choice) on port 8080, which forwards requests based on URL to the appropriate Tomcat instance running on a different port, such as 8081 or 8082.

Greg Hewgill
- 951,095
- 183
- 1,149
- 1,285
-
-
Alzzz, can you please re-read what Greg has proposed? Are you sure you understand this? – mindas Mar 21 '12 at 10:49
-
Greg Hewgill: if we run on 8081 or 8081 we need to mention like http://IPADDRESS:81/ to access the website. Where in the default is http://IPADDRESS . I want both my sites on 8080 even though as you saying I can do it my running multiple instances. – Alzzz Mar 21 '12 at 12:24
-
1@Alzzz: I think you are somewhat confused about ports and how they work. Port 8080 is *not* the same as port 80. The standard HTTP port is 80 (not 8080), and any other port requires that the user use the `:XX` port specifier in the URL. So running something on port 8080 would require that the user use `http://address:8080` to connect to it. Also, only *one* process can listen on any given port at one time. So you cannot run two instances of Tomcat listening on the same port on the same machine, unless you use a third server to proxy the requests to the correct instance of Tomcat. – Greg Hewgill Mar 21 '12 at 17:51
-
@Alzzz: It is possible. I have described how. I don't think you have understood what I have said, though. – Greg Hewgill Mar 21 '12 at 23:50
-
@Gereg you are saying :xx port should be specified in the url? How I tell all the users across the world to specify my port :xx in the url? – Alzzz Mar 22 '12 at 04:25
-
@Alzzz: You definitely have not understood what I have said. Run Apache (or whatever) on port 80. Run Tomcat A on port 8081, run Tomcat B on port 8082. Set up Apache to forward requests to Tomcat A or Tomcat B on the local machine depending on the URL. – Greg Hewgill Mar 22 '12 at 04:35
-
@Greg "Set up Apache to forward requests to Tomcat A or Tomcat B on the local machine depending on the URL"- in which folder I could do this setup? Do you have any online resource where in I could read this? – Alzzz Mar 22 '12 at 04:43
-
@Alzzz: The key words to look for in Google are "apache reverse proxy". If you have further questions about this, please create a new question on http://serverfault.com (this is technically off topic for Stack Overflow). Good luck! – Greg Hewgill Mar 22 '12 at 04:47
3
AFAIK, you can not run two different web servers at same port.

Lucifer
- 29,392
- 25
- 90
- 143
-
one server with multiple tomcat instances on same port. Any way to implement this? – Alzzz Mar 21 '12 at 07:08
0
You cannot do this.. Leave apart tomcat, this won't work with any combination of servers. Explain your requirements better

kishu27
- 3,140
- 2
- 26
- 41
-
I want to run 2 websites on mcahine with same port 8080. If I shutdown one server that should not affect the other server. – Alzzz Mar 21 '12 at 07:05
-
You may want to learn about virtual hosts setup. This is how multiple domains are setup on a single server. Basically, when a client browser tries to access a domain setup on a shared server, it sends three pieces on information to identify the target document. 1.> IP address of the server (using this the server is identified, 2.> Port of the server (using this the running application is identified, like tomcat) and 3.> Domain name, using this the website instance is identified. Setting up this configuration is called Virtual Hosts configuration. Look into it – kishu27 Mar 21 '12 at 07:08
-
And remmember that you "access" the two different sites by specifying different domain names. If you are doing this setup on a local machine (or on a network that doesn't have a DNS setup), you can use hosts file to setup your domain to IP mapping. – kishu27 Mar 21 '12 at 07:10
-
If you set up virtual host for this-For maintenance a website if I want shutdown my server, that would affect my other website which is running on the same machine. So setting virtual hosts will not meet my requirement. – Alzzz Mar 21 '12 at 07:25
-
-
-1
To or more instance of an application can be listening on the same port, as far the server supports portsharing ! Any request to this adr:port will be distributed among this different instances.