From dd1eadb1c739384123c0d7336125a4792062fcf6 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Tue, 22 Dec 2020 10:24:17 +0100
Subject: [PATCH] Encapsulate ip in apache access log to cover proxy forwarded
 multiple ips separated by comma and space

---
 templates/default     | 2 +-
 templates/default-ssl | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/templates/default b/templates/default
index 91865a3..3f12653 100644
--- a/templates/default
+++ b/templates/default
@@ -14,7 +14,7 @@
 {% if apache_version|default('2.4') == '2.4' %}
   ErrorLogFormat "[%{u}t] [%l] [pid %P] [client\ %{X-Forwarded-For}i] %M% ,\ referer:\ %{Referer}i"
 {% endif %}
-  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
+  LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined env=!forwarded
   CustomLog ${APACHE_LOG_DIR}/access.log proxy env=forwarded
diff --git a/templates/default-ssl b/templates/default-ssl
index 278dce5..c4f07ed 100644
--- a/templates/default-ssl
+++ b/templates/default-ssl
@@ -62,7 +62,7 @@
 {% if apache_version|default('2.4') == '2.4' %}
   ErrorLogFormat "[%{u}t] [%l] [pid %P] [client\ %{X-Forwarded-For}i] %M% ,\ referer:\ %{Referer}i"
 {% endif %}
-  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
+  LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
   ErrorLog ${APACHE_LOG_DIR}/gitlab-error.log
   CustomLog ${APACHE_LOG_DIR}/gitlab-access.log combined env=!forwarded
   CustomLog ${APACHE_LOG_DIR}/gitlab-access.log proxy env=forwarded
@@ -122,7 +122,7 @@
 {% if apache_version|default('2.4') == '2.4' %}
   ErrorLogFormat "[%{u}t] [%l] [pid %P] [client\ %{X-Forwarded-For}i] %M% ,\ referer:\ %{Referer}i"
 {% endif %}
-  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
+  LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
   ErrorLog ${APACHE_LOG_DIR}/mattermost-error.log
   CustomLog ${APACHE_LOG_DIR}/mattermost-access.log combined env=!forwarded
   CustomLog ${APACHE_LOG_DIR}/mattermost-access.log proxy env=forwarded
-- 
GitLab