Browse Source

Merge "Variable to set HTTP keepalive mode"

changes/03/645903/1
Zuul 4 months ago
parent
commit
ca51879876
3 changed files with 8 additions and 1 deletions
  1. 4
    0
      defaults/main.yml
  2. 1
    0
      templates/haproxy.cfg.j2
  3. 3
    1
      templates/service.j2

+ 4
- 0
defaults/main.yml View File

@@ -104,6 +104,10 @@ haproxy_connect_timeout: "10s"
104 104
 haproxy_http_request_timeout: "5s"
105 105
 # Set the maximum inactivity time on the server side
106 106
 haproxy_server_timeout: "50s"
107
+# Set the HTTP keepalive mode to use
108
+# Disable persistent connections by default because they can cause issues when the server side closes the connection
109
+# at the same time a request is sent.
110
+haproxy_keepalive_mode: 'forceclose'
107 111
 
108 112
 
109 113
 ## haproxy tuning params

+ 1
- 0
templates/haproxy.cfg.j2 View File

@@ -28,6 +28,7 @@ defaults
28 28
         log global
29 29
         option dontlognull
30 30
         option redispatch
31
+        option {{ haproxy_keepalive_mode }}
31 32
         retries {{ haproxy_retries }}
32 33
         timeout client {{ haproxy_client_timeout }}
33 34
         timeout connect {{ haproxy_connect_timeout }}

+ 3
- 1
templates/service.j2 View File

@@ -44,7 +44,9 @@ frontend {{ item.service.haproxy_service_name }}-front-{{ loop.index }}
44 44
 {% if request_option == "http" %}
45 45
     option httplog
46 46
     option forwardfor except 127.0.0.0/8
47
-    option http-server-close
47
+{% if item.service.haproxy_http_keepalive_mode is defined %}
48
+    option {{ item.service.haproxy_http_keepalive_mode }}
49
+{% endif %}
48 50
 {% elif request_option == "tcp" %}
49 51
     option tcplog
50 52
 {% endif %}

Loading…
Cancel
Save