CentOS 6.3 The Haproxy and Apache configuration process

Source: Internet
Author: User
Tags centos iptables haproxy

A. What is Haproxy

Haproxy provides high availability, load balancing, and proxies based on TCP and HTTP applications to support virtual hosts, a free, fast, and reliable solution. Haproxy is especially useful for Web sites that are heavily loaded, which typically require session maintenance or seven-tier processing. Haproxy is running on the current hardware and can support tens of thousands of concurrent connections altogether. and its operating mode makes it easy and secure to integrate into your current architecture while protecting your Web server from being exposed to the network.

Two. Install Haproxy

System Environment: centos6.3

apache:httpd-2.4.4

haproxy:haproxy-1.4.8

Haproxy server:192.168.7.198

Apache client1:192.168.7.196

Apache client2:192.168.7.197

Close Iptables and SELinux

# Service Iptables Stop

# Setenforce 0

# Vi/etc/sysconfig/selinux

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

Selinux=disabled

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

# wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.8.tar.gz

# tar ZXVF haproxy-1.4.8.tar.gz

# CD haproxy-1.4.8

# UNAME-A//view Linux kernel version

# Make Target=linux26 Prefix=/usr/local/haproxy

# Make Install Prefix=/usr/local/haproxy

# useradd-s/sbin/nologin Haproxy

# passwd Haproxy

# Chown-r Haproxy.haproxy/usr/local/haproxy

Three. Configure Haproxy

# vi/usr/local/haproxy/haproxy.cfg

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

Global

Maxconn 5120

Chroot/usr/local/haproxy

User Haproxy

Group Haproxy

Daemon

Quiet

Nbproc 2

Pidfile/usr/local/haproxy/haproxy.pid

Defaults

Log Global

Mode http

Option Httplog

Option Dontlognull

Log 127.0.0.1 Local3

Retries 3

Option Redispatch

Maxconn 2000

Contimeout 5000

Clitimeout 50000

Srvtimeout 50000

Listen web:80

Mode http

Balance Roundrobin

Option Httpclose

Option Forwardfor

Server client1 192.168.7.196:80 Check weight 1 minconn 1 Maxconn 3 check Inter 40000

Server Client2 192.168.7.197:80 Check weight 1 minconn 1 Maxconn 3 check Inter 40000

Listen stats:8888

Mode http

Transparent

Stats Uri/haproxy-stats

Stats Realm haproxy \ Statistic

#认证

Stats Auth Haproxy:password

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.