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.
Linux
The following instructions are required to setup the reverse proxy daemon:
- Boot the Linux instance and sudo to root.
- Install the module, type apt-get install libapache2-mod-proxy-html
- Installing the dependency libxml2-dev, type apt-get install libxml2-dev
- 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:
- Boot the Linux instance and sudo to root.
- Edit the apache configuration file, type vi /etc/apache2/sites-enabled/000-default.conf
- Within the <VirtualHost *:80></VirtualHost> braces, add the following lines…
- 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.
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
LikeLike
Hi Nate
My guess is that you’re not using a CentOs variant of Linux? Try using a Debian variant such as Ubuntu and this should work fine.
LikeLike