CentOS6.7 configure the HAProxy proxy transit configuration

Source: Internet
Author: User
Tags mkdir china vps vps iptables port number haproxy

HAProxy is a free, fast, and reliable proxy solution that supports high availability and server load balancer. It is also suitable for proxies for TCP and HTTP-based applications. For some websites with high load, HAProxy is particularly suitable. HAProxy supports tens of thousands of concurrent connections. It is easy to configure and can easily integrate into our existing application architecture.

Next, we will install and configure HAProxy on CentOS 6.7.

Installation method 1

Wget http://dl.cdn.ouu.me/VPS/haproxy/haproxy-1.6.2.tar.gz
Tar xvzf haproxy-1.6.2.tar.gz
Cd haproxy-1.6.2
Make TARGET = linux26
Make install
Mkdir-p/usr/local/haproxy/etc
Mkdir-p/usr/local/haproxy/sbin
Cp examples/haproxy. cfg/usr/local/haproxy/etc
Ln-s/usr/local/sbin/haproxy/usr/local/haproxy/sbin/haproxy
Vi/usr/local/haproxy/etc/haproxy. cfg

Configuration

The content of the installed configuration file is as follows:

Global
Ulimit-n 51200

ULTS
Log global
Mode tcp
Option dontlognull
Timeout connect 1000
Timeout client 150000
Timeout server 150000
       
# Set the ss Port for the transit server. Set the client connection to 9001 using the ip address of the mainland China vps.
Frontend 9001-sgp-in
Bind *: 9001
Default_backend 9001-sgp-out

# Set the ss Port for the transit server. Set the client connection to 9099 using the ip address of the mainland China vps.
Frontend 9099-hk-in
Bind *: 9099
Default_backend 9099-hk-out

# Set the ss Port for the transit server. Set the client connection to 8989 using the ip address of the mainland China vps.
Frontend 8989-jp-in
Bind *: 8989
Default_backend 8989-jp-out

# Ip address and port of Singapore vps where ss is deployed
Backend 9001-sgp-out
Server server1 xxx. xx. xx. xxx: 9001 maxconn 20480

# Ip address and port of the Hong Kong vps where ss is deployed
Backend 9099-hk-out
Server server1 xxx. xx. xx. xxx: 9099 maxconn 20480

# Ip address and port of the Japanese vps where ss is deployed
Back end 8989-jp-out
Server server1 xxx. xx. xx. xxx: 8989 maxconn 20480
Change the port number of the last line and the IP address and port number of the last line as needed.

Start the HAProxy agent

Then start Haproxy

Haproxy-f/usr/local/haproxy/etc/haproxy. cfg

Stop Haproxy

Killall haproxy

Finally, open the firewall Port. Otherwise, the data will be blocked.

/Sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT
/Etc/rc. d/init. d/iptables save

Installation method 2

Wget -- no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/haproxy.sh
Chmod + x haproxy. sh
./Haproxy. sh

Run the following command:

Start:/etc/init. d/haproxy start
Stop:/etc/init. d/haproxy stop
Restart:/etc/init. d/haproxy restart
Status:/etc/init. d/haproxy status

Configuration file path:/etc/haproxy. cfg

Installation method 3

Yum-y install haproxy

Uninstall method

Yum-y remove haproxy

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.