How to provision a Reverse Proxy in AWS

I recently needed to provision a reverse proxy in AWS to publish internally protected content out to the Internet. After a little research, I decided that Apache (with the mod_proxy module) would be a sensible choice given its support.

I was lead to believe that Ubuntu would be the platform of choice for this configuration due to its ease of setup and breadth of apparent online guides for configuration. A breeze, I thought!

However, I quickly realised that many of these guides led me down a dark rabbit hole and resulted in me hanging off the end of a useless link.

I managed to scramble some useful information together and eventually provisioned my first ever Reverse Proxy in AWS. I used the following instructions which I hope you find useful in repeating such a task.

AWS

I put together a very simple PoC in AWS comprising two instances; a back-end web server (Amazon Linux running Apache but could be anything) acting as the protected content and a Ubuntu Linux (again, under advice from various unreliable sources) instance running as the reverse proxy server. The web server is located in a private subnet and the reverse proxy server is in a public subnet. The following diagram illustrates the setup.

rp

Linux

The following instructions are required to setup the reverse proxy daemon:

  1. Boot the Linux instance and sudo to root.
  2. Install the module, type apt-get install libapache2-mod-proxy-html
  3. Installing the dependency libxml2-dev, type apt-get install libxml2-dev
  4. Load the modules, type the following:
  • a2enmod proxy proxy_http
  • a2enmod proxy_http
  • a2enmod proxy_http
  • a2enmod ssl
  • a2enmod proxy
  • a2enmod proxy_balancer
  • a2enmod proxy_http

The following instructions are required to configure the reverse proxy:

  1. Boot the Linux instance and sudo to root.
  2. Edit the apache configuration file, type vi /etc/apache2/sites-enabled/000-default.conf
  3. Within the <VirtualHost *:80></VirtualHost> braces, add the following lines…
  4. Save the file  and restart the daemon by typing /etc/init.d/apache2 restart

ProxyPass / <protected content URL>
ProxyPassReverse / <protected content URL>

Where / is the relative path of the proxy URL to redirect and <protected content URL> is the URL of the protected content you are publishing.

Proactive self-starter with a great breadth and depth of technical expertise. Extensive knowledge of cloud, Internet, and security technologies in addition to heterogeneous systems spanning Windows, *nix, virtualisation, application and systems management, networking, and automation. Evangelist of innovative technology, best practice, shrewd operational processes, and quality documentation. With an exceptional work ethic. Professional, diplomatic and approachable, always dependable and striving for customer satisfaction. Able to work well under pressure, independently or within a team, and use own initiative, with excellent communication skills and competence for designing and implementing creative solutions to quality, time and budget.

Tagged with: , , , , ,
Posted in AWS
2 comments on “How to provision a Reverse Proxy in AWS
  1. Nate Neu says:

    I am trying to make this work with no success.

    After I ssh into my aws and enter the commands specified I get the following output:

    [ec2-user@ip-xx-xx-xx-xx ~]$ apt-get install libapache2-mod-proxy-html
    -bash: apt-get: command not found

    Tried this too…

    [ec2-user@ip-xx-xx-xx-xx ~]$ install libapache2-mod-proxy-html
    install: missing destination file operand after ‘libapache2-mod-proxy-html’

    I am not super familiar with linux commands as it has been a long while, so if you could point me in the right direction that would be awesome.

    BTW I am using an single ec2 instance with linux (64 i believe?)

    Thanks

    Like

Leave a comment