From 3bdefe6212de18fb5c13fcbbf972f206dc5550cf Mon Sep 17 00:00:00 2001 From: alexanderM91 Date: Fri, 2 Feb 2024 11:40:47 +0100 Subject: [PATCH 1/3] SC-16767: Fix DNS cache for proxy-pass --- .../src/templates/nginx/http/proxy/reverse-proxy.conf.twig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig b/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig index af7e6fbd5..eaaec8a22 100644 --- a/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig +++ b/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig @@ -6,7 +6,8 @@ location {{ location }} { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; - proxy_pass {{ proxy_pass }}; + set $proxy_pass_endpoint {{ proxy_pass }}; + proxy_pass $proxy_pass_endpoint; } {% endfor %} From 4d482001791ce6a3b7a6db55920b38ed9953a986 Mon Sep 17 00:00:00 2001 From: alexanderM91 Date: Tue, 1 Oct 2024 12:59:03 +0200 Subject: [PATCH 2/3] Update the with the proxy_bind --- generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig b/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig index eaaec8a22..3bb51b3bb 100644 --- a/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig +++ b/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig @@ -6,6 +6,7 @@ location {{ location }} { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; + proxy_bind $remote_addr transparent; set $proxy_pass_endpoint {{ proxy_pass }}; proxy_pass $proxy_pass_endpoint; } From 463ca6796617811519c4fed03c7557757e9722bf Mon Sep 17 00:00:00 2001 From: alexanderM91 Date: Tue, 1 Oct 2024 15:48:33 +0200 Subject: [PATCH 3/3] Resolver logic improvements --- generator/src/templates/nginx/entrypoint.sh.twig | 5 +++-- .../src/templates/nginx/http/proxy/reverse-proxy.conf.twig | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generator/src/templates/nginx/entrypoint.sh.twig b/generator/src/templates/nginx/entrypoint.sh.twig index 4f12ec3c8..015c12993 100644 --- a/generator/src/templates/nginx/entrypoint.sh.twig +++ b/generator/src/templates/nginx/entrypoint.sh.twig @@ -9,12 +9,13 @@ export SPRYKER_NGINX_CGI_{{ applicationName | upper}}=${SPRYKER_NGINX_CGI_{{ (ap {% endfor %} {% endfor %} -envsubst '{{ envVariables | join(' ') }}' < /etc/nginx/template/default.conf.tmpl > /etc/nginx/conf.d/default.conf - if [ -z "${SPRYKER_DNS_RESOLVER_IP}" ]; then export SPRYKER_DNS_RESOLVER_IP=$(grep "nameserver" /etc/resolv.conf | awk '{print $2}') + {% set envVariables = envVariables | merge(["\$SPRYKER_DNS_RESOLVER_IP"]) %} fi +envsubst '{{ envVariables | join(' ') }}' < /etc/nginx/template/default.conf.tmpl > /etc/nginx/conf.d/default.conf + envsubst '$SPRYKER_DNS_RESOLVER_IP ${SPRYKER_DNS_RESOLVER_FLAGS} {{ envVariables | join(' ') }}' < /etc/nginx/template/resolver.conf.tmpl > /etc/nginx/conf.d/00-resolver.conf if [ -n "${SPRYKER_XDEBUG_MODE_ENABLE}" ]; then diff --git a/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig b/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig index 3bb51b3bb..6ec928c59 100644 --- a/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig +++ b/generator/src/templates/nginx/http/proxy/reverse-proxy.conf.twig @@ -1,15 +1,14 @@ {% block proxy %} {% for location, proxy_pass in endpointData['proxy'] %} location {{ location }} { + resolver ${SPRYKER_DNS_RESOLVER_IP} valid=1s; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; - proxy_bind $remote_addr transparent; set $proxy_pass_endpoint {{ proxy_pass }}; proxy_pass $proxy_pass_endpoint; } - {% endfor %} {% endblock proxy %}