Showing posts with label mod proxy. Show all posts
Showing posts with label mod proxy. Show all posts

Monday, March 12, 2012

Building Apache HTTPD Load Balancer from trunk on Ubuntu 11.10

This post discusses how to install Apache Module mod_proxy_balancer locally.
However, you can just configure mod_proxy load balancer using the builds, without using the source.
Downloading the sources
Download the HTTPD source and extract it
http://httpd.apache.org/download.cgi#apache24

Download APR, APR-Util, and pcre
http://apr.apache.org/download.cgi
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.zip


Unpacking
Unpack APR and APR-Util into ./srclib/apr and ./srclib/apr-util
Be sure the domain names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/
Extract pcre as well.

Building pcre
Go to pcre root directory
sudo ./configure --enable-unicode-properties
make
sudo make install

Configure HTTPD Load Balancer
Go to the httpd root folder.

./configure --with-included-apr --enable-proxy --enable-proxy-balancer
make
sudo make install

Now you have installed the Apache HTTPD Load Balancer locally, to its default location $APACHE2_HOME - /usr/local/apache2/. You can configure it to balance the load across your service instances that to be load balanced.

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/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
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 .example.com
        

        # 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