How to forward ports using Apache

How to…

Use Apache to forward port 80 to another application

So I was trying to install Atlassian JIRA for project management and wanted to be able to access it with jira.example.com instead of jira.example.com:8080.  Typical users aren’t used to having to type port numbers in the browser bar, so here is a way to forward the default HTTP port (80) to another port (8080, in this case).  This was done on Ubuntu 14.04.

Install Apache

sudo apt-get install apache2

Enable Proxy

sudo a2enmod apache2

Edit site config file

Look for your current site configuration file in: /etc/apache2/sites-enabled

vi path/to/file/file.conf

Comment out the existing code

copy and paste this and edit to your needs:

<VirtualHost *:80>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName www.example.com
  ServerAlias example.com
  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/
</VirtualHost>

Restart Apache

sudo service apache restart