Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using environment variables in nginx configuration not working because of renew certificates command #100

Open
igi-1w3r53n opened this issue Dec 1, 2020 · 2 comments

Comments

@igi-1w3r53n
Copy link

Related: nginxinc/docker-nginx#422 (comment)

I am using env variables in my docker-compose file and i was not able to get this setup running. It seems that nginx ignores its default commands and template compilation when the "command: "/bin/sh -c 'while :; do sleep 6h ..." renew certificates command is set in docker-compose file.

Maybe someone has a similar issue.

@toastyrye
Copy link

toastyrye commented Dec 9, 2020

envsubst can be used to support environmental variables. see here:
https://serverfault.com/questions/577370/how-can-i-use-environment-variables-in-nginx-conf

this could also be a feature to add to the repo

@c-mart
Copy link

c-mart commented Mar 14, 2023

Yes, the ENTRYPOINT script (invoked here) appears responsible for this behavior. If the first argument to the container's CMD (as defined in command: in docker-compose.yml) is not nginx or nginx-debug, then the entrypoint script never looks for the 20-envsubst-on-templates.sh script. That is the case with the docker-compose.yml in this repo, because the command: starts with a while loop to reload Nginx every 6 hours.

I got it working by modifying the command: to run the envsubst script before starting Nginx:

command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & /docker-entrypoint.d/20-envsubst-on-templates.sh; nginx-debug -g \"daemon off;\"'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants