haproxy.cfg.j2 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. global
  2. log /dev/log local0
  3. log /dev/log local1 notice
  4. {% if haproxy_socket != '' %}
  5. stats socket {{ haproxy_socket }} level admin
  6. {% endif %}
  7. {% if haproxy_chroot != '' %}
  8. chroot {{ haproxy_chroot }}
  9. {% endif %}
  10. user {{ haproxy_user }}
  11. group {{ haproxy_group }}
  12. daemon
  13. {% for global_var in haproxy_global_vars %}
  14. {{ global_var }}
  15. {% endfor %}
  16. defaults
  17. log global
  18. mode http
  19. option httplog
  20. option dontlognull
  21. {% if haproxy_version is version('1.4', '<=') %}
  22. contimeout {{ haproxy_connect_timeout }}
  23. clitimeout {{ haproxy_client_timeout }}
  24. srvtimeout {{ haproxy_server_timeout }}
  25. {% else %}
  26. timeout connect {{ haproxy_connect_timeout }}
  27. timeout client {{ haproxy_client_timeout }}
  28. timeout server {{ haproxy_server_timeout }}
  29. {% endif %}
  30. {% if ansible_os_family == 'Debian' %}
  31. errorfile 400 /etc/haproxy/errors/400.http
  32. errorfile 403 /etc/haproxy/errors/403.http
  33. errorfile 408 /etc/haproxy/errors/408.http
  34. errorfile 500 /etc/haproxy/errors/500.http
  35. errorfile 502 /etc/haproxy/errors/502.http
  36. errorfile 503 /etc/haproxy/errors/503.http
  37. errorfile 504 /etc/haproxy/errors/504.http
  38. {% endif %}
  39. frontend {{ haproxy_frontend_name }}
  40. bind {{ haproxy_frontend_bind_address }}:{{ haproxy_frontend_port }}
  41. mode {{ haproxy_frontend_mode }}
  42. default_backend {{ haproxy_backend_name }}
  43. backend {{ haproxy_backend_name }}
  44. mode {{ haproxy_backend_mode }}
  45. balance {{ haproxy_backend_balance_method }}
  46. option forwardfor
  47. {% if haproxy_backend_httpchk != '' %}
  48. option httpchk {{ haproxy_backend_httpchk }}
  49. {% endif %}
  50. cookie SERVERID insert indirect
  51. {% for backend in haproxy_backend_servers %}
  52. server {{ backend.name }} {{ backend.address }} cookie {{ backend.name }} check
  53. {% endfor %}