Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Linux VPS. Configuration Linux CentOS with cPanel Default port :80

Servers running Apache for PHP (default in cPanel) Tomcat 5.5.33

I have a only 1 IP alloted for it. Have multiple domains hosted on it.

MY PROBLEM: All domains are running on port :80 but i need only 1 of my domain to run in port :8080

I'm able to access my domain as but i need to access it as (8080 should deliver instead of default 80)

My references

share|improve this question

If I understand correctly, you want to transparently access the tomcat content on by simply accessing - there's a few methods to do this:

1) if you have mod-rewrite enabled, try something like this in your vhost definition or in a .htaccess file

RewriteEngine on
RewriteCond  %{SERVER_PORT} !^8080$
RewriteRule ^(.*) http://%{SERVER_NAME}:8080%{REQUEST_URI} 

2) if you wanna back-proxy it (needs mod_proxy_http enabled)

share|improve this answer
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 in browser (it redirects to 404error ) – mohan.hab Aug 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. – Bruno Aug 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_jk2 (from @O G's link) is considered "historical".
  • 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).
share|improve this answer
up vote 0 down vote accepted

I had found solution from the hints given in previous posts

.htaccess file

RewriteEngine on
RewriteBase /
RewriteRule ^admin(.*)$$1 [R,L]
RewriteRule ^(.*)$$1 [R,L]


ProxyPass         /try
ProxyPassReverse  /try
ProxyPass         /tryAdmin
ProxyPassReverse  /tryAdmin


Apache - /etc/httpd/conf/httpd.conf Tomcat - /usr/local/jakarta/apache-tomcat-5.5.33/conf/server.xml


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.