Sunday, May 22, 2016

Allow public access to web applications deployed within a private network

Scenario:
You have a web application currently deployed within a private network. You would like your friends to test the application over the Internet.

Solution:
One option is to set up a public server with the configuration similar to the one on the private network. However, this approach is tedious and costly especially if for testing purposes only.
An alternative is to use the proxying capabilities of Apache, in particular reverse proxying.

Requirements:

  • Ubuntu Server 14.04 LTS with a public IP address and a private IP address (which is connected to the private network where the web application is running)
Steps:
  1. Install and enable the required apache modules.
    1. sudo apt-get install apache2 libapache2-mod-proxy-html
    2. sudo a2enmod proxy_html
  2. Edit the /etc/apache2/sites-enabled/000-default. Add the following inside the VirtualHost directive, reflecting your own settings.
    1. ProxyPass "/myapp" "http://private_ip_hosting_the_app"
    2. ProxyPassReverse "/myapp" "http://private_ip_hosting_the_app"
  3. Restart Apache.
    1. sudo service apache2 restart
  4. Visit http://public_ip_of_server/myapp to test
Final Notes:
You can add as many web applications as you want. Here is an example.

0 comments: