Using Reverse Proxy in Apache to allow multiple domain names via DynDns or No-ip.org

So I have these accounts (free) from DynDns.org (or even No-ip.org) and the goal is that, I wanted to have two sources of exposed host names or domain names publicly with these two free domain (sub domains) from the said dns services.


My setup is that, I have two machine (technically, one is running natively in my machine and the other one is via virtual machine). Let's call it A machine and B machine respectively.


So A machine is where my apache is running. Currently, I have version 2.2.2

So how do I do it,

I have these two domains namely,

http://a-machine.dyndns.org
http://b-machine.dyndns.org


In my A machine, it's running in Mac OS X and I have these PHP project that I wanted to exposed publicly, while in my B machine running in Ubuntu, I wanted to expose my J2EE project publicly.

In A machine, I can directly allow in my httpd.conf (or in my setup, I have extended it to an external file namely httpd-vhosts.conf), and add,


<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /Users/someonelse/httpd-apps/facebookapp
    ServerName a-machine.dyndns.org
    ErrorLog /private/var/log/apache2/a-machine-error_log
    CustomLog /private/var/log/apache2/a-machine-access_log common
</VirtualHost>


Then for my B machine to be "reverse proxy" via Apache, i just have these also after the line in my httpd-vhosts.conf,



<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerName dev-gogie.dyndns.org
   ProxyRequests on
   ProxyPass / http://10.0.1.111/
   ProxyPassReverse / http://10.0.1.111/
</VirtualHost>


Take note of the trailing slash at the end of the ProxyPass IP (or host name/domain name if you do specify). You can also change, instead of an IP, to a domain name or host name either if its specified by your router, or defined via your /etc/hosts file. With the trailing slash added, it'll be no problem of locating your static files (js, css, images, etc.).


Again, so in my A machine, I have these in my httpd-vhosts.conf below.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /Users/someonelse/httpd-apps/facebookapp
    ServerName a-machine.dyndns.org
    ErrorLog /private/var/log/apache2/a-machine-error_log
    CustomLog /private/var/log/apache2/a-machine-access_log common
</VirtualHost>
<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerName dev-gogie.dyndns.org   ProxyRequests on
   ProxyPass / http://10.0.1.111/
   ProxyPassReverse / http://10.0.1.111/
</VirtualHost>

Hope this helps. Enjoy!


Comments

Popular posts from this blog

Converting sectors into MB - Useful in understanding the sectors in iostat in Linux

What is Disk Contention?

Installing MySQL from source: Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)