Friday, August 26, 2016

Different types of Computer Hard Disk Drive and its Connectors


A hard disk drive also called hard drive, hard disk or disk drive is a device used for storing and retrieving digital data or information. A hard disk is a stack of disk known as the platter. A single hard disk usually consists of several platters and each platter requires two read/write heads, one for each side and is attached to a single access arm. Data are recorded electromagnetically in a concentric circle such as the track on a disk.

A hard disk speed can vary from 4500rpm - 7200rpm for Parallel ATA and 10000rpm to 15000rpm for SCSI drive and Serial Attached SCSI (SAS). Hard drive with 10000rpm to 15000rpm is more expensive than lower rpm drives, this kind of HDD are used primarily on servers that are used for transaction processing databases, internet infrastructure such as email, web server that require intensive data processing and operate continuously. HDD that are running 10,000rpm to 15,000rpm has smaller platters to lessen the power requirements and therefore have lower capacity than desktop computer drives.

harddisk drive parts

  • actuator :
    Used to position the head arms to different tracks on the surface of the platter, actuator is used in changing from track to track the only operation on the hard disk that requires active movement. This mechanism of hard disk must works at extreme speed, with precise accuracy for the data to be read and write accurately on the platter.


Different types of Hard disk drive (HDD)



Parallel ATAParallel Advance Technology Attachment (PATA) drives are also known as Integrated Drive Electronics (IDE) developed by Western Digital under the name Integrated Drive Electronics (IDE)





Small Computer System Interface (SCSI) Hard driveSmall Computer System Interface or SCSI for short and can be pronounce as "skuzzy" are high performance storage drives. SCSI drives are commonly found in servers were real time performance or 24/7 operation is required. SCSI drive are much faster than the standard drive Parallel ATA (PATA) with 5400RPM - 7200RPM access time compared to 10000RPM - 15000RPM for SCSI. Revolution Per Minute "RPM" of hard drives is a measurement of how many complete revolutions a computer's hard drive makes in a single minute. Fast rotation speed of the spindle means high data transfer , the higher the RPM, the faster the data will be accessed

2.5 inch IDE DriveParallel Advance Technology Attachment (PATA) drives are also known as Integrated Drive Electronics (IDE) with 2.5 inch form factor. Due to its smaller size it is commonly used in notebook PCs, external storage, gaming consoles, and portable video players.



Serial ATA DriveSerial ATA was designed to replace the older parallel ATA (PATA). SATA offers several advantages over the older IDE drive such as reduced cable size reducing from 40 pins in IDE to 7 pins in SATA, native hot swapping and has faster data transfer through higher signaling rates.



Serial Attached SCSI (SAS)The Serial Attached SCSI (SAS) is a new generation serial communication protocol for devices designed to allow for much higher speed data transfers and is compatible with SATA. The serial transmission of data requires fewer connections and eliminates the SCSI bus and still uses the very capable SCSI protocol. SAS uses a mechanically identical data and power connector to standard 3.5-inch SATA1/SATA2 HDDs and many server-oriented SAS RAID controllers are also capable of addressing SATA hard drives. SATA drives can be attached to a SAS drive controller and they will work perfectly because they are compatible but not SAS drive connected to a SATA controller this configuration will not work.


URL Redirect and Virtual Hosting

URL Redirect

<VirtualHost *:80>
    ServerAdmin root@example.com
    DocumentRoot /usr/local/apache/httpdocs/
    ServerName hrms.example.com
    ServerAlias www.hrms.example.com
RewriteEngine On
Options +FollowSymlinks
 Redirect  /  http://10.10.10.2:81/login
</VirtualHost>


-----------------------------------------------------------------------------------------------------------


<VirtualHost *:80>
DocumentRoot /usr/local/apache/htdocs/example/redirection
ServerName www.example.com
ServerAlias example.com
ServerAdmin root@example.com
DirectoryIndex ip_redirect.php
<Directory /usr/local/apache/htdocs/example/redirection>
        AllowOverride All
        Order allow,deny
        Allow from all
        Options +Includes +ExecCGI -Indexes
</Directory>
CustomLog "|/usr/sbin/rotatelogs /usr/local/apachelogs/example.com_%Y-%m-%d.log 86400" combined 
ErrorLog /usr/local/apachelogs/example_error.log_%Y-%m-%d.log
</VirtualHost>


-------------------------------------------------------------------------------------------------------------


<VirtualHost *:80>
DocumentRoot /usr/local/apache/htdocs/example_doc
ServerName www.example.com
ServerAlias example.com
ServerAdmin root@example.com
DirectoryIndex index.php
<Directory /usr/local/apache/htdocs/example_doc>
        AllowOverride All
        Order allow,deny
        Allow from all
        Options +Includes +ExecCGI -Indexes
</Directory>
CustomLog "|/usr/sbin/rotatelogs /usr/local/apachelogs/example.com.log 86400" common
ErrorLog /usr/local/apachelogs/example.com_error.log
</VirtualHost>

Apache Virtual Host documentation ( IP-based and Name-based )

The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.
Below is a list of documentation pages which explain all details of virtual host support in Apache HTTP Server:

Virtual Host Support


  • Name-based Virtual Hosts (More than one web site per IP address)
  • IP-based Virtual Hosts (An IP address for each web site)
  • Virtual Host examples for common setups
  • File Descriptor Limits (or, Too many log files)
  • Dynamically Configured Mass Virtual Hosting
  • In-Depth Discussion of Virtual Host Matching

Configuration directives


  • NameVirtualHost
  • <VirtualHost>
  • ServerName
  • ServerAlias
  • ServerPath
If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:
/usr/local/apache2/bin/httpd -S
This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options)

Apache IP-based Virtual Host Support



What is IP-based virtual hosting

IP-based virtual hosting is a method to apply different directives based on the IP address and port a request is received on. Most commonly, this is used to serve different websites on different ports or interfaces.
In many cases, name-based virtual hosts are more convenient, because they allow many virtual hosts to share a single address/port. See Name-based vs. IP-based Virtual Hosts to help you decide.

System requirements

As the term IP-based indicates, the server must have a different IP address/port combination for each IP-based virtual host. This can be achieved by the machine having several physical network connections, or by use of virtual interfaces which are supported by most modern operating systems (see system documentation for details, these are frequently called "ip aliases", and the "ifconfig" command is most commonly used to set them up), and/or using multiple port numbers.
In the terminology of Apache HTTP Server, using a single IP address but multiple TCP ports, is also IP-based virtual hosting

How to set up Apache

There are two ways of configuring apache to support multiple hosts. Either by running a separate httpd daemon for each hostname, or by running a single daemon which supports all the virtual hosts.
Use multiple daemons when:
  • There are security partitioning issues, such as company1 does not want anyone at company2 to be able to read their data except via the web. In this case you would need two daemons, each running with different UserGroupListen, and ServerRoot settings.
  • You can afford the memory and file descriptor requirements of listening to every IP alias on the machine. It's only possible to Listen to the "wildcard" address, or to specific addresses. So if you have a need to listen to a specific address for whatever reason, then you will need to listen to all specific addresses. (Although one httpd could listen to N-1 of the addresses, and another could listen to the remaining address.)
Use a single daemon when:
  • Sharing of the httpd configuration between virtual hosts is acceptable.
  • The machine services a large number of requests, and so the performance loss in running separate daemons may be significant.

Setting up multiple daemons

Create a separate httpd installation for each virtual host. For each installation, use the Listen directive in the configuration file to select which IP address (or virtual host) that daemon services. e.g.
Listen 192.168.0.1:80
It is recommended that you use an IP address instead of a hostname (see DNS caveats).

Setting up a single daemon with virtual hosts

For this case, a single httpd will service requests for the main server and all the virtual hosts. The VirtualHost directive in the configuration file is used to set the values of ServerAdminServerNameDocumentRootErrorLog and TransferLog or CustomLog configuration directives to different values for each virtual host. e.g.
<VirtualHost 192.168.0.1:80>
ServerAdmin webmaster@smallco.example.com
DocumentRoot /groups/smallco/www
ServerName smallco.example.com
ErrorLog /groups/smallco/logs/error_log
TransferLog /groups/smallco/logs/access_log
</VirtualHost>

<VirtualHost 192.168.0.2:80>
ServerAdmin webmaster@baygroup.example.org
DocumentRoot /groups/baygroup/www
ServerName baygroup.example.com
ErrorLog /groups/baygroup/logs/error_log
TransferLog /groups/baygroup/logs/access_log
</VirtualHost>
It is recommended that you use an IP address instead of a hostname in the <VirtualHost> directive (see DNS caveats).
Specific IP addresses or ports have precedence over their wildcard equivalents, and any virtual host that matches has precedence over the servers base configuration.
Almost any configuration directive can be put in the VirtualHost directive, with the exception of directives that control process creation and a few other directives. To find out if a directive can be used in the VirtualHost directive, check the Context using the directive index.
SuexecUserGroup may be used inside a VirtualHost directive if the suEXEC wrapper is used.
SECURITY: When specifying where to write log files, be aware of some security risks which are present if anyone other than the user that starts Apache has write access to the directory where they are written. See the security tips document for details.


Name-based Virtual Host Support



Name-based vs. IP-based Virtual Hosts

IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many different hosts can share the same IP address.
Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Name-based virtual hosting also eases the demand for scarce IP addresses. Therefore you should use name-based virtual hosting unless you are using equipment that explicitly demands IP-based hosting. Historical reasons for IP-based virtual hosting based on client support are no longer applicable to a general-purpose web server, unless you are using a mod_ssl version without SNI support (standard in Apache releases since 2.2.12).

Using Name-based Virtual Hosts


To use name-based virtual hosting, you must designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the NameVirtualHost directive. In the normal case where any and all IP addresses on the server should be used, you can use * as the argument toNameVirtualHost. If you're planning to use multiple ports (e.g. running SSL) you should add a Port to the argument, such as *:80. Note that mentioning an IP address in a NameVirtualHost directive does not automatically make the server listen to that IP address. See Setting which addresses and ports Apache uses for more details. In addition, any IP address specified here must be associated with a network interface on the server.
The next step is to create a <VirtualHost> block for each different host that you would like to serve. The argument to the <VirtualHost> directive must match a defined NameVirtualHost directive. (In this usual case, this will be "*:80"). Inside each <VirtualHost> block, you will need at minimum a ServerName directive to designate which host is served and a DocumentRoot directive to show where in the filesystem the content for that host lives.

Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName andDocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.
For example, suppose that you are serving the domain www.domain.tld and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address. Then you simply add the following to httpd.conf:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
You can alternatively specify an explicit IP address in place of the * in both the NameVirtualHost and <VirtualHost> directives. For example, you might want to do this in order to run some name-based virtual hosts on one IP address, and either IP-based, or another set of name-based virtual hosts on another address.
Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example in the first <VirtualHost> block above, the ServerAlias directive indicates that the listed names are other names which people can use to see that same web site:
ServerAlias domain.tld *.domain.tld
then requests for all hosts in the domain.tld domain will be served by the www.domain.tld virtual host. The wildcard characters * and ? can be used to match names. Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server.
The complete list of names in the VirtualHost directive are treated just like a (non wildcard) ServerAlias.
Finally, you can fine-tune the configuration of the virtual hosts by placing other directives inside the <VirtualHost> containers. Most directives can be placed in these containers and will then change the configuration only of the relevant virtual host. To find out if a particular directive is allowed, check the Context of the directive. Configuration directives set in the main server context (outside any <VirtualHost> container) will be used only if they are not overridden by the virtual host settings.
Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each <VirtualHost>section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.
As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches theNameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a<VirtualHost> container and list it first in the configuration file.

Compatibility with Older Browsers

As mentioned earlier, there are some clients who do not send the required data for the name-based virtual hosts to work properly. These clients will always be sent the pages from the first virtual host listed for that IP address (the primary name-based virtual host).

How much older?

Please note that when we say older, we really do mean older. You are very unlikely to encounter one of these browsers in use today. All current versions of any browser send the Host header as required for name-based virtual hosts.
There is a possible workaround with the ServerPath directive, albeit a slightly cumbersome one:
Example configuration:
NameVirtualHost 111.22.33.44

<VirtualHost 111.22.33.44>
ServerName www.domain.tld
ServerPath /domain
DocumentRoot /web/domain
</VirtualHost>
What does this mean? It means that a request for any URI beginning with "/domain" will be served from the virtual host www.domain.tld. This means that the pages can be accessed as http://www.domain.tld/domain/ for all clients, although clients sending a Host: header can also access it as http://www.domain.tld/.
In order to make this work, put a link on your primary virtual host's page to http://www.domain.tld/domain/. Then, in the virtual host's pages, be sure to use either purely relative links (e.g., "file.html" or "../icons/image.gif") or links containing the prefacing /domain/ (e.g., "http://www.domain.tld/domain/misc/file.html" or "/domain/misc/file.html").
This requires a bit of discipline, but adherence to these guidelines will, for the most part, ensure that your pages will work with all browsers, new and old.

How to setup HAProxy as Load Balancer for Nginx on CentOS 7

HAProxy or High Availability Proxy is an open source TCP and HTTP load balancer and proxy server software. HAProxy has been written by Willy Tarreau in C, it supports SSL, compressions, keep-alive, custom log formats and header rewriting. HAProxy is a fast and lightweight proxy server and load balancer with a small memory footprint and low CPU usage. It is used by large sites like Github, StackOverflow, Reddit, Tumblr, Twitter and others. It has become the most popular software load balancer and proxy server in the past years.
In this tutorial, I will guide you trough the HAProxy installation and configuration for 3 servers, one load balancer, and two Nginx web servers. We will install HAProxy on a single server and then install Nginx web server on the other servers. HAProxy acts as a load balancer for the Nginx web servers.

Basic Concept with HAProxy

Ref : https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts

ref : https://dzone.com/articles/how-to-configure-ha-proxy-as-a-proxy-and-loadbalan

Layer 4 and Layer 7

HAProxy can run in two modes: TCP mode Layer 4 and HTTP Mode Layer 7. In Layer 4 TCP mode, HAProxy forwards the RAW TCP packets from the client to the application servers. In the Layer 7 HTTP mode, HAProxy is parsing the HTTP header before forwarding them to the application servers. In this tutorial, we will use Nginx as the web server that only supports the Layer 7 HTTP mode.

Balance Algorithm

This is the algorithm that is used by HAProxy to select the server when doing the load balancing. The following modes are available:
Roundrobin
This is the most simple balance algorithm. For each new connection, it will be handled by the next backend server. If the last backend server in the list is reached, it will start again from the top of backend list.
Lastconn
The new connection will be handled by the backend server with least amount of connections. This is useful when the time and load of the requests vary a lot.
Source
This is for sticky sessions, the client IP will be hashed to determine the backend server that received the last request from this IP. So an IP A will always be handled by backend1, and IP B will always be handled by banckend2 to not interrupt sessions
There are oOther algorithm - check the official HAProxy site for details.

Prerequisites

  • 3 CentOS 7
            loadbalancer
            192.168.1.102

           nginx1
           192.168.1.104

            nginx2
            192.168.1.105
  • Root privileges on all 3 servers.

Step 1 - Configure the /etc/hosts files

Log in to the load balancer server and edit the /etc/hosts file.
ssh loadbalancer@192.168.1.102
sudo su
vi /etc/hosts
Add nginx1 and nginx2 hostnames:
192.168.1.104    nginx1.loadbalancer.me     nginx1
192.168.1.105    nginx2.loadbalancer.me     nginx2
Save the file and exit the editor.
Next, edit the hosts file on the Nginx servers (nginx1 and nginx2):
ssh nginx1@192.168.1.104
ssh nginx2@192.168.1.105
Edit and add a new line for the load balancer in the hosts files:
vi /etc/host
Add the loadbalancer hostname on each nginx server:
192.168.1.102    loadbalancer
do this on nginx1 and nginx2 server.

Step 2 - Install and Configure HAProxy

HAProxy is available in the CentOS 7 repository, log in to the loadbalancer server and update the package lists:
ssh loadbalancer@192.168.1.104
yum -y update
Now install HAProxy with this yum command:
yum -y install haproxy
When the installation is finished, go to the "/etc/haproxy/" directory and backup the original configuration file:
cd /etc/haproxy/
mv haproxy.cfg haproxy.cfg.orig
Next, add a new HAProxy configuration file "haproxy.cfg" file with the vi editor:
vi haproxy.cfg
Paste the configuration below:
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log         127.0.0.1 local2     #Log configuration
 
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000                
    user        haproxy             #Haproxy running under user and group "haproxy"
    group       haproxy
    daemon
 
    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats
 
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000
 
#---------------------------------------------------------------------
#HAProxy Monitoring Config
#---------------------------------------------------------------------
listen haproxy3-monitoring *:8080                #Haproxy Monitoring run on port 8080
    mode http
    option forwardfor
    option httpclose
    stats enable
    stats show-legends
    stats refresh 5s
    stats uri /stats                             #URL for HAProxy monitoring
    stats realm Haproxy\ Statistics
    stats auth howtoforge:howtoforge            #User and Password for login to the monitoring dashboard
    stats admin if TRUE
    default_backend app-main                    #This is optionally for monitoring backend
 
#---------------------------------------------------------------------
# FrontEnd Configuration
#---------------------------------------------------------------------
frontend main
    bind *:80
    option http-server-close
    option forwardfor
    default_backend app-main
 
#---------------------------------------------------------------------
# BackEnd roundrobin as balance algorithm
#---------------------------------------------------------------------
backend app-main
    balance roundrobin                                     #Balance algorithm
    option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost    #Check the server application is up and healty - 200 status code
    server nginx1 192.168.1.104:80 check                 #Nginx1 
    server nginx2 192.168.1.105:80 check                 #Nginx2
Save the configuration file and exit.
Next, configure rsyslog for HAProxy.
We will configure the rsyslog daemon to log the HAProxy statistics. Edit the rsyslog.conf file to enable the UDP port 514 to be used by rsyslog.
vi /etc/rsyslog.conf
Uncomment this line to enable the UDP connection:
$ModLoad imudp
$UDPServerRun 514
If you want to use a specific IP, you can add a new line like the one below:
$UDPServerAddress 127.0.0.1
Save the file and exit.
Then create new haproxy configuration file for rsyslog:
cd /etc/rsyslog.d/
vi haproxy.conf
Paste configuration below:
local2.=info     /var/log/haproxy-access.log    #For Access Log
local2.notice    /var/log/haproxy-info.log      #For Service Info - Backend, loadbalancer
Save and exit.
Now restart rsyslog and then start the haproxy:
systemctl restart rsyslog
systemctl start haproxy
Add haproxy to start at boot time:
systemctl enable haproxy

Step 3 - Install and Configure Nginx

In this section, we will install Nginx from epel repository on nginx1 and nginx2 server.
Log in to the servers:
ssh nginx1@192.168.1.104
ssh nginx2@192.168.1.105
Install the epel repository with the yum command below:
yum -y install epel-release
Now you can install Nginx:
yum -y install nginx
Nginx is installed. Go to the web directory and change the index file so that we can see which of the two servers delivered the html file:
cd /usr/share/nginx/html/
echo "<h1>nginx1.loadbalance.me</h1>" > index.html     #For nginx1 server
echo "<h1>nginx2.loadbalance.me</h1>" > index.html     #For nginx2 server
Next, add Nginx to start at boot time and then start it:
systemctl enable nginx
systemctl start nginx
Make sure you're doing this step on nginx1 and nginx2 server.

Step 4 - Testing

Testing from browser by accessing the loadbalancer IP: 192.168.1.102
Request handled by Nginx 1
Request handled by Nginx 2
Testing with curl command:
curl 192.168.1.102
Test HAProxy
Testing to login to the HAProxy web monitoring that is running on port 8080 with username and password "howtoforge":
http://192.168.1.102:8080/stats
HAProxy Statstics
HAProxy is working  successfully and acts as a load balancer for our two Nginx web servers.
############################################
stop httpd server on haproxy server or change the haproxy port
frontend  main 10.1.0.75:80
##################################################

Conclusion

HAProxy or High Availability proxy is an open source software that provides high availability for TCP-based services, it operates as HTTP load balancer and proxy server. The software is written in C and supports SSL, keep-alive and compression. HAProxy is the right choice for everyone who needs a load balancer and proxy server that is fast and lightweight with a small memory footprint and low CPU usage. Haproxy can run in Layer 4 TCP mode and Layer 7 HTTP mode. Nginx supports only the Layer 7 HTTP mode with HAProxy. If you want to use Layer 4 TCP mode, you can use other web servers like apache. On CentOS 7, HAProxy is available in the default repository. It's easy to install and configure.

############################################################

 cat /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend  main 10.1.0.75:81
    default_backend             app

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
    balance     roundrobin
#    server      static 127.0.0.1:80 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
    balance     roundrobin
    server  app1 10.12.0.34:80 check
    server  app2 10.12.1.48:80 check