2.5. Examples

  1. # Simple configuration for an HTTP proxy listening on port 80 on all
  2. # interfaces and forwarding requests to a single backend "servers" with a
  3. # single server "server1" listening on 127.0.0.1:8000
  4. global
  5. daemon
  6. maxconn 256
  7.  
  8. defaults
  9. mode http
  10. timeout connect 5000ms
  11. timeout client 50000ms
  12. timeout server 50000ms
  13.  
  14. frontend http-in
  15. bind *:80
  16. default_backend servers
  17.  
  18. backend servers
  19. server server1 127.0.0.1:8000 maxconn 32
  20.  
  21.  
  22. # The same configuration defined with a single listen block. Shorter but
  23. # less expressive, especially in HTTP mode.
  24. global
  25. daemon
  26. maxconn 256
  27.  
  28. defaults
  29. mode http
  30. timeout connect 5000ms
  31. timeout client 50000ms
  32. timeout server 50000ms
  33.  
  34. listen http-in
  35. bind *:80
  36. server server1 127.0.0.1:8000 maxconn 32
  37.  
  38.  
  39. Assuming haproxy is in $PATH, test these configurations in a shell with:
  40.  
  41. $ sudo haproxy -f configuration.conf -c