haproxy.cfg.j2 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Global settings
  2. #---------------------------------------------------------------------
  3. global
  4. chroot /var/lib/haproxy
  5. pidfile /var/run/haproxy.pid
  6. maxconn {{ haproxy_global_maxconn | default('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 300s
  29. timeout server 300s
  30. timeout http-keep-alive 10s
  31. timeout check 10s
  32. maxconn {{ haproxy_default_maxconn | default('3000') }}
  33. listen stats :9000
  34. mode http
  35. stats enable
  36. stats uri /
  37. {% for frontend in haproxy_frontends %}
  38. frontend {{ frontend.name }}
  39. {% for bind in frontend.binds %}
  40. bind {{ bind }}
  41. {% endfor %}
  42. default_backend {{ frontend.default_backend }}
  43. {% if 'mode' in frontend %}
  44. mode {{ frontend.mode }}
  45. {% endif %}
  46. {% if 'options' in frontend %}
  47. {% for option in frontend.options %}
  48. option {{ option }}
  49. {% endfor %}
  50. {% endif %}
  51. {% if 'redirects' in frontend %}
  52. {% for redirect in frontend.redirects %}
  53. redirect {{ redirect }}
  54. {% endfor %}
  55. {% endif %}
  56. {% endfor %}
  57. {% for backend in haproxy_backends %}
  58. backend {{ backend.name }}
  59. balance {{ backend.balance }}
  60. {% if 'mode' in backend %}
  61. mode {{ backend.mode }}
  62. {% endif %}
  63. {% if 'options' in backend %}
  64. {% for option in backend.options %}
  65. option {{ option }}
  66. {% endfor %}
  67. {% endif %}
  68. {% for server in backend.servers %}
  69. server {{ server.name }} {{ server.address }} {{ server.opts }}
  70. {% endfor %}
  71. {% endfor %}