Allow to disable keepalive
There's a race condition when a client makes a request "at the same
time" the HTTP connection is being closed by Apache because the
`KeepAliveTimeout` is expired.
This is explained in detail and can be reproduce using
https://github.com/mikem23/keepalive-race or
https://github.com/JordanP/openstack-snippets/blob/master/keepalive-race/keep-alive-race.py
Just disable KeepAlive to fix the
('Connection aborted.', BadStatusLine("''",)) error we are seeing.
Related-Prod: PROD-18148
Change-Id: I1061a937f6bca11ffb556604c216bf11c6db4006
diff --git a/apache/files/_core.conf b/apache/files/_core.conf
new file mode 100644
index 0000000..7aa0cea
--- /dev/null
+++ b/apache/files/_core.conf
@@ -0,0 +1,15 @@
+
+ {#- Disable KeepAlive to fix bug #1630664 a.k.a the #}
+ {#- ('Connection aborted.', BadStatusLine("''",)) error #}
+ {%- if site.get('keepalive', {}).enabled is defined %}
+ {%- set keepalive = 'On' if site.keepalive.enabled else 'Off' %}
+ {%- elif site.get('ssl', {}).get('enabled') %}
+ {%- set keepalive = 'Off' %}
+ {%- endif %}
+
+ {%- if keepalive is defined %}
+ KeepAlive {{ keepalive }}
+ {%- endif %}
+ {%- if site.get('keepalive', {}).timeout is defined %}
+ KeepAliveTimeout {{ site.keepalive.timeout }}
+ {%- endif %}
diff --git a/apache/files/wsgi.conf b/apache/files/wsgi.conf
index 2a62735..23f9afe 100644
--- a/apache/files/wsgi.conf
+++ b/apache/files/wsgi.conf
@@ -11,6 +11,7 @@
{%- include "apache/files/_name.conf" %}
{%- include "apache/files/_wsgi.conf" %}
{%- include "apache/files/_ssl.conf" %}
+ {%- include "apache/files/_core.conf" %}
{%- include "apache/files/_log.conf" %}
{%- include "apache/files/_limits.conf" %}