Explorar o código

feat: execute upstream nginx entrypoint

Nicolas Duchon hai 1 ano
pai
achega
f1f395c10b

+ 6 - 1
app/docker-entrypoint.sh

@@ -110,12 +110,17 @@ if [[ $* == 'forego start -r' ]]; then
 
 	_setup_dhparam
 
-	if [ -z "${TRUST_DOWNSTREAM_PROXY}" ]; then
+	if [[ -z "${TRUST_DOWNSTREAM_PROXY}" ]]; then
 		cat >&2 <<-EOT
 			Warning: TRUST_DOWNSTREAM_PROXY is not set; defaulting to "true". For security, you should explicitly set TRUST_DOWNSTREAM_PROXY to "false" if there is not a trusted reverse proxy in front of this proxy.
 			Warning: The default value of TRUST_DOWNSTREAM_PROXY might change to "false" in a future version of nginx-proxy. If you require TRUST_DOWNSTREAM_PROXY to be enabled, explicitly set it to "true".
 		EOT
 	fi
+
+	# Execute upstream nginx entrypoint if present
+	if [[ -f /docker-entrypoint.sh ]]; then
+		/docker-entrypoint.sh nginx -v
+	fi
 fi
 
 exec "$@"

+ 1 - 0
test/test_nginx-entrypoint/test.conf.template

@@ -0,0 +1 @@
+# some_directive ${TEST_VARIABLE};

+ 6 - 0
test/test_nginx-entrypoint/test_nginx-entrypoint.py

@@ -0,0 +1,6 @@
+import pytest
+
+
+def test_templatefile_was_rendered_by_nginx_entrypoint(docker_compose, nginxproxy):
+    conf = nginxproxy.get_conf().decode('ASCII')
+    assert "# some_directive FOOBARBAZ;" in conf

+ 10 - 0
test/test_nginx-entrypoint/test_nginx-entrypoint.yml

@@ -0,0 +1,10 @@
+version: "2"
+
+services:
+  sut:
+    image: nginxproxy/nginx-proxy:test
+    environment:
+      TEST_VARIABLE: "FOOBARBAZ"
+    volumes:
+      - /var/run/docker.sock:/tmp/docker.sock:ro
+      - ./test.conf.template:/etc/nginx/templates/test.conf.template:ro