haproxy_http.cfg.j2 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. global
  2. log 127.0.0.1 local2
  3. chroot /var/lib/haproxy
  4. pidfile /var/run/haproxy.pid
  5. user haproxy
  6. group haproxy
  7. maxconn 5000
  8. nbproc 2
  9. cpu-map 1 0
  10. cpu-map 2 1
  11. daemon
  12. tune.ssl.default-dh-param 2048
  13. stats socket /var/lib/haproxy/stats mode 660 level admin
  14. listen stats
  15. bind :9000
  16. mode http
  17. stats enable
  18. stats hide-version
  19. stats show-node
  20. stats realm Haproxy\ Statistics
  21. stats uri /haproxy_stats
  22. stats auth admin:admin # Authentication credentials
  23. timeout connect 86400
  24. timeout client 86400
  25. timeout server 86400
  26. defaults
  27. mode tcp
  28. log global
  29. option tcplog
  30. option dontlognull
  31. option http-server-close
  32. option forwardfor except 127.0.0.0/8
  33. option redispatch
  34. retries 3
  35. timeout http-request 10
  36. timeout queue 1m
  37. timeout connect 1m
  38. timeout client 1m
  39. timeout server 1m
  40. timeout http-keep-alive 10
  41. timeout check 10
  42. frontend ft_http
  43. bind *:80
  44. mode http
  45. timeout client 1m
  46. default_backend bk_http
  47. frontend ft_https
  48. bind *:443
  49. mode tcp
  50. timeout client 1m
  51. http-request set-header X-Forwarded-Proto: https
  52. default_backend bk_https
  53. #frontend ft_mix
  54. # mode http
  55. # bind *:80
  56. # bind *:443 ssl crt {{ ssl_crt_path }}/{{ ssl_name }}.pem
  57. # http-request redirect scheme https code 301 if !{ ssl_fc }
  58. # http-response set-header Strict-Transport-Security max-age=63072000
  59. # default_backend bk_mix
  60. #
  61. #backend bk_mix
  62. # mode http
  63. # balance {{ backend_balance_method }}
  64. # default-server inter 1s
  65. # timeout connect 10s
  66. # timeout server 1m
  67. # {% if haproxy_backend_servers != '' %}
  68. # {% for item in haproxy_backend_servers %}
  69. # server {{ item }} {{ hostvars[item]['ansible_host'] }}:80 maxconn 250 check id {{ loop.index }}
  70. # {% endfor %}
  71. # {% endif %}
  72. backend bk_http
  73. mode http
  74. balance {{ backend_balance_method }}
  75. default-server inter 1s
  76. timeout connect 10s
  77. timeout server 1m
  78. {% if haproxy_backend_servers != '' %}
  79. {% for item in haproxy_backend_servers %}
  80. server {{ item }} {{ hostvars[item]['ansible_host'] }}:80 maxconn 250 check id {{ loop.index }}
  81. {% endfor %}
  82. {% endif %}
  83. backend bk_https
  84. mode tcp
  85. balance {{ backend_balance_method }}
  86. option ssl-hello-chk
  87. default-server inter 1s
  88. timeout connect 10s
  89. timeout server 1m
  90. {% if haproxy_backend_servers != '' %}
  91. {% for item in haproxy_backend_servers %}
  92. server {{ item }} {{ hostvars[item]['ansible_host'] }}:443 maxconn 250 check id {{ loop.index }}
  93. {% endfor %}
  94. {% endif %}