From 12f7e9360c0988665630f5d27d21a03d4117370a Mon Sep 17 00:00:00 2001
From: nd <git@notandy.de>
Date: Fri, 27 Oct 2023 11:48:16 +0200
Subject: [PATCH] fix configuration for unused pages_listen and
 pages_listen_ssl (proxy setup)

---
 templates/gitlab.rb.j2 | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/templates/gitlab.rb.j2 b/templates/gitlab.rb.j2
index a40dc8b..39e642b 100644
--- a/templates/gitlab.rb.j2
+++ b/templates/gitlab.rb.j2
@@ -1403,10 +1403,17 @@ pages_external_url "{{ gitlab.pages_external_url }}"
 gitlab_pages['enable'] = true
 
 ##! Configure to expose GitLab Pages on external IP address, serving the HTTP
+{% if gitlab.pages_listen %}
 gitlab_pages['external_http'] = {{ gitlab.pages_listen|to_json }}
+{% endif %}
 
 ##! Configure to expose GitLab Pages on external IP address, serving the HTTPS
+{% if gitlab.pages_listen_ssl %}
 gitlab_pages['external_https'] = {{ gitlab.pages_listen_ssl|to_json }}
+{% endif %}
+
+##! Listen for requests forwarded by reverse proxy
+gitlab_pages['listen_proxy'] = '{{ gitlab.pages_listen_proxy }}'
 
 ##! Configure to use the default list of cipher suites
 # gitlab_pages['insecure_ciphers'] = false
@@ -1429,9 +1436,6 @@ gitlab_pages['external_https'] = {{ gitlab.pages_listen_ssl|to_json }}
 # gitlab_pages['sentry_dsn'] = 'https://<key>@sentry.io/<project>'
 # gitlab_pages['sentry_environment'] = 'production'
 
-##! Listen for requests forwarded by reverse proxy
-gitlab_pages['listen_proxy'] = '{{ gitlab.pages_listen_proxy }}'
-
 ##! Configure GitLab Pages to use an HTTP Proxy
 # gitlab_pages['http_proxy'] = "http://example:8080"
 
@@ -1473,7 +1477,9 @@ gitlab_pages['access_control'] = true
 # gitlab_pages['gitlab_client_jwt_expiry'] = "30s"
 
 ##! Define custom gitlab-pages HTTP headers for the whole instance
+{% if gitlab.pages_headers %}
 gitlab_pages['headers'] = {{ gitlab.pages_headers|to_json }}
+{% endif %}
 
 ##! Shared secret used for authentication between Pages and GitLab
 # gitlab_pages['api_secret_key'] = nil # Will be generated if not set. Base64 encoded and exactly 32 bytes long.
-- 
GitLab