The port forwarding is working. But i need to mask the 8080 port from browser view. Also If i need to forward the above to some subfolder as default, how can i make it? RewriteRule ^(.*) http://%{SERVER_NAME}:8080/sub%{REQUEST_URI} is causing problem while i try to access example.com/admin in browser (it redirects to example.com/sub/admin 404error )
–
mohan.habAug 20 '11 at 8:01

@mohan.hab, if you want to "mask the 8080 port" (i.e. use port 80), you need to use one of the reverse proxy methods, not mod_rewrite.
–
BrunoAug 20 '11 at 12:41

You get two categories of options: redirection or reverse proxy (which you can do within a specific VirtualHost configuration, if you need this to be for only one host name).

The redirection can be done using mod_rewrite (as @O G says).

Since the server running on port 8080 is effectively a different server from Apache HTTPD on port 80, mod_rewrite can't rewrite URLs internally (so it only works in redirection mode). Instead, you can use a reverse proxy method:

mod_jk is rather stable, but it relies on the AJP protocol, so you wouldn't need to enable it on your Tomcat configuration (probably not on port 8080).

mod_proxy_ajp is also rather stable and often comes by default with Apache HTTPD (unlike mod_jk), at least with version 2.2. It also uses the AJP protocol, so you would need to configure Apache Tomcat accordingly too.

Otherwise, you could use an HTTP reverse proxy, with mod_proxy_http (without the need for AJP).