Differences
This shows you the differences between two versions of the page.
— |
how-to:set-up-haproxy [2016-02-25 19:28:51] (current) rory.blanchard created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== How to Set up HAProxy on CentOS ====== | ||
+ | HAProxy is a service that can help with load balancing of web servers, or just proxying traffic. We recommend installing through the Epel repository to keep the packages updated. | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== Install Epel: ===== | ||
+ | Run the following commands: | ||
+ | |||
+ | < | ||
+ | yum -y install epel-release | ||
+ | </ | ||
+ | |||
+ | If yum does not find the epel-release package, please see [[https:// | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== Install HAProxy ===== | ||
+ | |||
+ | Run the following command: | ||
+ | |||
+ | < | ||
+ | yum -y install haproxy | ||
+ | </ | ||
+ | |||
+ | Once it has been installed, you can edit the config file by running the following: | ||
+ | |||
+ | < | ||
+ | nano / | ||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== Sample configuration for Web Server Proxy ===== | ||
+ | |||
+ | < | ||
+ | global | ||
+ | # Where to save the logs, | ||
+ | log | ||
+ | chroot | ||
+ | pidfile | ||
+ | # Max connections per process | ||
+ | maxconn | ||
+ | # User and group process runs under | ||
+ | user haproxy | ||
+ | group | ||
+ | daemon | ||
+ | |||
+ | defaults | ||
+ | # Mode the server is running in | ||
+ | mode http | ||
+ | log global | ||
+ | option | ||
+ | timeout connect | ||
+ | timeout client | ||
+ | timeout server | ||
+ | |||
+ | # Define Frontend (set any name for http-in section) | ||
+ | frontend http-in | ||
+ | # Set server to listen on port 80 | ||
+ | bind *:80 | ||
+ | # Set default backend to forward traffic to | ||
+ | default_backend | ||
+ | option | ||
+ | |||
+ | # Define Backend server with roundrobin mode | ||
+ | backend backend_servers | ||
+ | # Set balance type as roundrobin | ||
+ | balance | ||
+ | # Define backend servers | ||
+ | server | ||
+ | server | ||
+ | </ | ||
+ | |||
+ | ===== Auto-start for CentOS 7 ===== | ||
+ | |||
+ | To get HAproxy to run automatically after configuration run the following commands: | ||
+ | |||
+ | < | ||
+ | systemctl start haproxy | ||
+ | systemctl enable haproxy | ||
+ | </ | ||
+ | \\ | ||
+ | \\ |