Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning

If you want to modify the config file, you need to check the validity also. Please check command here: be root and modify the file as explained here https://confluence.ecmwf.int/display/EWCLOUDKB/How+to+modify+HAproxy+config+file. You will find also more general info about the config and a way to validate your changes.

  1. Open haproxy config file at /opt/ha-proxy-certbot/haproxy/config and start modifying the config

In HAProxy, a frontend receives traffic before dispatching it to

...

backend, which is a pool of web or application servers. One of the servers in the backend will receive the request, form a response, and then send the response back through HAProxy to the client.

In your HAProxy configuration, below the frontend section, add a backend section that contains a single server. Also, add a default_backend line to your frontend that points to this new backend. Your file now looks like this:

Code Block
defaults
  mode http
  timeout client 10s
  timeout connect 5s
  timeout server 10s 
  timeout http-request 10s

frontend myfrontend
  bind *:80
  default_backend myservers

backend myservers
  server server1 127.0.0.1:8000

You can also add multiple backends:

Code Block
defaults
  mode http
  timeout client 10s
  timeout connect 5s
  timeout server 10s 
  timeout http-request 10s

frontend myfrontend
  bind *: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.


2. After saving the changes, the changes should take effect in the haproxy container.

3. You can check the validity with the following command

Code Block
docker exec -it <CONTAINER_ID> haproxy -c -f /config/haproxy.cfg

where CONTAINER_ID, can be found using docker ps

Add health checks

https://www.haproxy.com/blog/how-to-enable-health-checks-in-haproxy

...