Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to port forward apache's 80 to Glassfish's 8080 using proxy configuration

Recently, I'm developing and testing an application deployed on Glassfish that runs on port 8080. Then I do need the app to run on port 80, since I don't want to change the default port of Glassifh from 8080 to 80, I've just installed apache and try port forwarding, it worked and here's how I did it (I've done it in Ubuntu 11.10).

1.) Make sure that you have download, installed and configured Glassfish to run on port 8080. (Just need to download the zipped file from oracle: http://glassfish.java.net/downloads/).

2.) Download, installed and configured apache on port 8080.
sudo apt-get install apache2

3.) Enable proxy, proxy_http and rewrite modules on apache:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod rewrite

4.) Create your custom apache proxy configuration file inside /etc/apache2/conf.d
NameVirtualHost *:80
<VirtualHost *:80>
 ProxyPreserveHost on
 RewriteEngine on
 ProxyPass / http://localhost:8080/
 ProxyPassReverse / http://localhost:8080/
 Redirect / http://localhost:8080/
 RewriteRule ^/(.*) http://localhost:8080/$1 [P,L]
</VirtualHost>
How to port forward apache's 80 to Glassfish's 8080 using proxy configuration How to port forward apache's 80 to Glassfish's 8080 using proxy configuration Reviewed by Edward Legaspi on Sunday, July 22, 2012 Rating: 5

2 comments:

Anonymous said...

Thanks a lot for this tutorial. However what i need to do is to forward apache's 80 to Glassfish's 8181.
I have a certificate already installed on glassfish, and a java E app that has in web.xml : CONFIDENTIAL. So how to forward to https without seing the port 8181 in the url?
thanks a lot

Anonymous said...

Very good tutorial

Thank you!

Powered by Blogger.