1

I have setup tomcat 6 on a server with several different instances which run on different ports

For Eg:

     http://10.XXX.XXX.XXX:8080/myAPP1
     http://10.XXX.XXX.XXX:8088/myAPP2
     http://10.XXX.XXX.XXX:8082/myAPP3

and so on...

These urls are available two the users using these and other applications Now I want to hide the ports on which each of the applications are running...

So that the user could see only something like this

http://10.XXX.XXX.XXX/myAPP1
http://10.XXX.XXX.XXX/myAPP2
http://10.XXX.XXX.XXX/myAPP3

What is needed to be done for this

I have achieved this for one url (i.e. one port) using the firewall rules and redirect the request on HTTP 80 port to the port that tomcat is listening..

But I want such patter to appear for all the urls...

How can I go about this?

Specs

HOST M/C : 64 bit

OS: Linux Redhat

Tomcat : 6.0

2 Answers 2

3

Install a real webserver, like Apache or nginx, and use it's built-in proxying capabilities (mod_proxy on Apache, and HttpProxy core module on nginx) to proxy the path to the appropriate Tomcat application running on a high port.

1
  • Thanks. But could you give me a little bit more details about it or say may be a link to a guide or something that can guide me to how to go about this process...
    – S.M.09
    Mar 29, 2012 at 9:42
3

Install apache and use mod_rewrite to proxy the requests to the backend tomcat applications.

Here's a sample snippet of apache config that should do it:

RewriteEngine on
#Optional - setup a log, useful for debugging
#RewriteLog logs/rewrite.log
#RewriteLogLevel 3

RewriteRule ^/myAPP1(.*) http://10.XXX.XXX.XXX:8080/myAPP1$1 [P,L]
RewriteRule ^/myAPP2(.*) http://10.XXX.XXX.XXX:8088/myAPP2$1 [P,L]
RewriteRule ^/myAPP3(.*) http://10.XXX.XXX.XXX:8082/myAPP3$1 [P,L]

Here's some helpful info regard mod_rewrite: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/

2
  • I tried using ReverseProxy and was successful in achieving the result. Could you tell me the difference in using Reverseproxy and RewriteRule. I would like to give Rewriterule a try especially if it makes a difference in the response time to the client.
    – S.M.09
    Apr 1, 2012 at 15:39
  • mod_rewrite is powerful and does more than proxying requests. Check out the documentation or some of the mod_rewrite guides available. It allows regular expression matching and URL manipulation. Apr 4, 2012 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .