From f1f395c10b517c232a5877f2e26e7ba4a645670f Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Sat, 4 May 2024 20:47:07 +0200 Subject: [PATCH] feat: execute upstream nginx entrypoint --- app/docker-entrypoint.sh | 7 ++++++- test/test_nginx-entrypoint/test.conf.template | 1 + test/test_nginx-entrypoint/test_nginx-entrypoint.py | 6 ++++++ test/test_nginx-entrypoint/test_nginx-entrypoint.yml | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/test_nginx-entrypoint/test.conf.template create mode 100644 test/test_nginx-entrypoint/test_nginx-entrypoint.py create mode 100644 test/test_nginx-entrypoint/test_nginx-entrypoint.yml diff --git a/app/docker-entrypoint.sh b/app/docker-entrypoint.sh index 0477dd2..fc89538 100755 --- a/app/docker-entrypoint.sh +++ b/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 "$@" diff --git a/test/test_nginx-entrypoint/test.conf.template b/test/test_nginx-entrypoint/test.conf.template new file mode 100644 index 0000000..681665e --- /dev/null +++ b/test/test_nginx-entrypoint/test.conf.template @@ -0,0 +1 @@ +# some_directive ${TEST_VARIABLE}; diff --git a/test/test_nginx-entrypoint/test_nginx-entrypoint.py b/test/test_nginx-entrypoint/test_nginx-entrypoint.py new file mode 100644 index 0000000..4722e05 --- /dev/null +++ b/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 diff --git a/test/test_nginx-entrypoint/test_nginx-entrypoint.yml b/test/test_nginx-entrypoint/test_nginx-entrypoint.yml new file mode 100644 index 0000000..0786300 --- /dev/null +++ b/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