haproxy.cfg.j2 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Global settings
  2. #---------------------------------------------------------------------
  3. global
  4. chroot /var/lib/haproxy
  5. pidfile /var/run/haproxy.pid
  6. maxconn 4000
  7. user haproxy
  8. group haproxy
  9. daemon
  10. # turn on stats unix socket
  11. stats socket /var/lib/haproxy/stats
  12. #---------------------------------------------------------------------
  13. # common defaults that all the 'listen' and 'backend' sections will
  14. # use if not designated in their block
  15. #---------------------------------------------------------------------
  16. defaults
  17. mode http
  18. log global
  19. option httplog
  20. option dontlognull
  21. option http-server-close
  22. option forwardfor except 127.0.0.0/8
  23. option redispatch
  24. retries 3
  25. timeout http-request 10s
  26. timeout queue 1m
  27. timeout connect 10s
  28. timeout client 1m
  29. timeout server 1m
  30. timeout http-keep-alive 10s
  31. timeout check 10s
  32. maxconn 3000
  33. {% for frontend in haproxy_frontends %}
  34. frontend {{ frontend.name }}
  35. {% for bind in frontend.binds %}
  36. bind {{ bind }}
  37. {% endfor %}
  38. default_backend {{ frontend.default_backend }}
  39. {% if 'mode' in frontend %}
  40. mode {{ frontend.mode }}
  41. {% endif %}
  42. {% if 'options' in frontend %}
  43. {% for option in frontend.options %}
  44. option {{ option }}
  45. {% endfor %}
  46. {% endif %}
  47. {% if 'redirects' in frontend %}
  48. {% for redirect in frontend.redirects %}
  49. redirect {{ redirect }}
  50. {% endfor %}
  51. {% endif %}
  52. {% endfor %}
  53. {% for backend in haproxy_backends %}
  54. backend {{ backend.name }}
  55. balance {{ backend.balance }}
  56. {% if 'mode' in backend %}
  57. mode {{ backend.mode }}
  58. {% endif %}
  59. {% if 'options' in backend %}
  60. {% for option in backend.options %}
  61. option {{ option }}
  62. {% endfor %}
  63. {% endif %}
  64. {% for server in backend.servers %}
  65. server {{ server.name }} {{ server.address }} {{ server.opts }}
  66. {% endfor %}
  67. {% endfor %}