Redirect the request from Apache to tomcat using mod_proxy

If you want to redirect the apache request to tomcat[8080],use mod_proxy module.

Eg:

You want access http://192.168.1.10:8080/support with this url example.com/support.

Please go to virtual host entry for example.com in httpd.conf,

<VirtualHost 192.168.1.10:80>
ServerAdmin support@example.com
DocumentRoot /var/www/example.com/public_html
ServerName example.com
ServerAlias www.example.com
ScriptAlias /cgi-bin/ /var/www/example.com/public_html/cgi-bin
#Options +Indexes
<Directory /var/www/example.com/public_html/cgi-bin>
AddHandler cgi-script .cgi .pl
</Directory>
ProxyPass /support/ http://192.168.1.10:8080/support/
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>


Also if you want to redirect some specific url's to another port use below method,

ProxyPassReverse / http://%{HTTP_HOST}:8080/
RewriteEngine on
RewriteCond  %{REQUEST_URI} .*\.(flv|mp4|mp3)$
RewriteRule ^/(.*) http://%{HTTP_HOST}:8080/$1 [P]

In this above example, requests for flv,mp4 & mp3 are redirected to port 8080 and then remaining ports are handled on regular port 80.

Comments

Popular posts from this blog

Using a Linux server to route packets between two private networks

PHP Fatal error: Class 'JFactory' not found

KVM & Qemu