Use port 80 instead of port 8080 on web application

This is a quick post that solves the problem of converting your server (using an application developed and deployed for port 8080) to serve on port 80.

To modify the application itself is not a really good idea as it has side effects and can affect updates.

To modify iptables is an option but this only works if the person viewing the site is allowed to leave their gateway on port 8080 to get redirected to 80 on arrival at the web server. In my case this is not possible as our proxy blocks port 8080 egress.

You would just change the port allocated in the server container by modifying say the server.xml file however that means your application will now have to be started as root for reasons beyond the scope of this blog.

After a fair amount of reading (which I am learning pays off every time) I have come up with a solution that requires you to type 4 lines and is over in 2 minutes.

Lets get started shall we…

I am using Ubuntu so I installed apache2

sudo apt-get install apache2

Added 2 lines to the apache2.conf file

ProxyPass    /    http://localhost:8080/
ProxyPassReverse    /    http://localhost:8080/

I then enabled the already existing mod_proxy. The following command restart apache (thanks Ubuntu)

sudo a2enmod proxy

and there you have it, a user will now be able to reach your http://www.server:8080/stuff on http://www.server/stuff.

If you are using different protocols such as AJP and your web application sends redirects etc there are other modules available, however that is beyond the scope of this blog post.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s