...
Code Block |
---|
defaults mode http timeout client 10s timeout connect 5s timeout server 10s timeout http-request 10s frontend myfrontend bind 127.0.0.1*:80 |
This example includes:
...
The load balancer is now listening on the localhost address, 127.0.0.1, at port 80. If you make a request using curl
, you’ll get back a response:
Code Block |
---|
$ curl 1270.0.0.10:80 <html><body><h1>503 Service Unavailable</h1> No server is available to handle this request. </body></html> |
...
Code Block |
---|
defaults mode http timeout client 10s timeout connect 5s timeout server 10s timeout http-request 10s frontend myfrontend bind 127.0.0.1*:80 default_backend myservers backend myservers server server1 127.0.0.1:8000 |
...
Code Block |
---|
defaults mode http timeout client 10s timeout connect 5s timeout server 10s timeout http-request 10s frontend myfrontend bind 127.0.0.1*:80 default_backend myservers backend myservers server server1 127.0.0.1:8000 server server2 127.0.0.1:8001 server server3 127.0.0.1:8002 |
With each new request that you make to port 80, HAProxy receives it and selects a server to handle it. HAProxy rotates through the list of servers, relaying the next request to the next server in line. You are now balancing the load across these servers.
Add health checks
https://www.haproxy.com/blog/how-to-enable-health-checks-in-haproxy
Resources
https://www.haproxy.com/blog/haproxy-configuration-basics-load-balance-your-servers