Wednesday, February 24, 2016

httpd proxy to redirect port 8080 to port 80 in tomcat7 on Linux server(RHEL/CentOS/Amazon Linux)

Here I have redirected tomcat7 service running in port 8080 to port 80 and another httpd service is also running in port 80.

Domain Name : mydomain.com
Hosting address1: mail.mydomain.com(httpd)
Hosting address2: mydomain.com(tomcat7)
Server : Linux

edit httpd conf file /etc/httpd/conf/httpd.conf and add the below lines



<VirtualHost mail.mydomain.com:80>
ServerName mail.mydomain.com
#ServerAlias mail.*
ServerAdmin support@mydomain.com
DocumentRoot /var/www/html/squirrelmail
#SSLEngine on
#SSLCertificateFile /etc/httpd/conf/ssl/mailcert.pem
#SSLCertificateKeyFile /etc/httpd/conf/ssl/mailkey.pem
</VirtualHost>



<VirtualHost mydomain.com:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ProxyTimeOut 320
<Location />
Order allow,deny
Allow from all
</Location>
ProxyRequests Off
ProxyPreserveHost On
ProxyPassReverseCookiePath / /
<IfModule mod_rewrite.c>
# Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^bharathjeeva\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
</IfModule>
ErrorDocument 503 /errors/503.html
ErrorDocument 502 /errors/502.html
</VirtualHost>



Save and restart httpd service by



#/etc/init.d/httpd restart
or

#service httpd restart

No comments:

Post a Comment