Sunday, March 11, 2012

Configuring Apache mod_proxy load balancer

Installing Apache2 Server
sudo apt-get install apache2
sudo /etc/init.d/apache2 restart
Setting up HTTPS
sudo a2enmod ssl
sudo a2ensite default-ssl
Setting up load balancing modules
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
Now enable mod_proxy in Apache, and proxy requests to the application server by adding the example below to your Apache httpd.conf
# Put this after the other LoadModule directives
LoadModule proxy_module /usr/lib/apache2/modules/
LoadModule proxy_http_module /usr/lib/apache2/modules/
cd /etc/apache2/mods-available
sudo vim proxy.conf 

        # set ProxyRequests off since we're only using the ProxyPass and ProxyPassReverse
        # directives. this keeps the server secure from
        # spammers trying to use your proxy to send email.

        ProxyRequests Off

                AddDefaultCharset off
                Order deny,allow
                Allow from all
                #Allow from

        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On

    Order deny,allow
    Allow from all

sudo apt-get install libapache2-mod-proxy-html 
cd /usr/local/apache2/conf
Add the below line to httpd.conf
Include conf/extra/httpd-proxy-balancer.conf

Restart and reload the server
sudo service apache2 restart
sudo service apache2 reload


  1. something is missing i.e loadbalance configuration is not ther

    1. Hi,
      I can not understand your comment completely. Could you rephrase it, or provide the error message?

  2. I am using 32 bit ubuntu so i had to figure out which directories to include. It worked pretty nicely. Kudos to you for posting these steps. Thanks.

    1. Glad to hear that this was useful for you. :)

  3. Hi,
    i have tried to follow those steps but this /usr/local/apache2/conf is no find
    and when i tried to Include conf/extra/httpd-proxy-balancer.conf
    the error comes


You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.