@samara
To load balance and redirect with HAProxy, follow these steps:
1
|
sudo apt-get install haproxy |
1 2 3 4 5 6 7 8 9 10 |
frontend my_frontend bind *:80 acl is_website hdr(host) -i example.com use_backend website_servers if is_website backend website_servers balance roundrobin option http-server-close server server1 192.168.1.1:8080 check server server2 192.168.1.2:8080 check |
This configuration snippet sets up a frontend that listens on port 80 and redirects traffic to the backend server based on the requested host. The backend server then balances the traffic between server1 and server2 using a round-robin algorithm.
1
|
sudo service haproxy restart |
By following these steps, you can set up load balancing and redirection with HAProxy to improve the performance and availability of your web application.