Comments on 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. 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.

14 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: khoiu

Seems like it didn't work.

When i was testing by browsing to the load balancer's IP: It just display nginx1 even when i pressed F5 many times.

By: yume

Check your haproxy log and configuration.

On my vm centos7 - this tutorial is work perfectly..

By: doancongtuan111

this is simple :) thanks you so much :)

By: Bernard

Thanks a lot dude!! It works!

By: phuongna

HAProxy is available in the CentOS 7 repository, log in to the loadbalancer server and update the package lists:

ssh [email protected] -> 192.168.1.102

By: dude

thanks!

By: Cooler

Cooling...

By: Leland Later

Thank you very much for this helpful tutorial.

By: Ramnath

 

Hi, Looks good article. Can I get the same step by step procedure for SFTP load balacing with HAProxy Pl.I need this on priority.

 

Thanks in advance.

By: blah

this is not working for me. the haproxy stats shows my servers are down and logs show no server avalible when i start haproxy.

I can only open the web app on the machine it is set on. nginx1 only opens on nginx1. I thinking it has something to do with my hosts file or host names but im not that good at linux.

By: Rohan Terani

Under the HAProxy balance algorithm, it should be leastconn and not lastconn for the description you have given.

By: Sirous

The best Doc !

You made my day :)

By: vassa metayasha

don't forget to add =

firewall-cmd --permanent --add-service=http

 

firewall-cmd --reload

By: Bola OUSSOU

Hi

Thanks for this tuto. Please i just nee one clarification

does Haproxy has to be on "mode http" or "mode tcp" in case Nginx is alrady managing SSL certificate decryption ?

I have faced some issues where sites won't display in this config you described . Only being in "mode tcp" forward the raw traffic to Nginx