-
Notifications
You must be signed in to change notification settings - Fork 0
nginx use system env. var.
DUONG Phu-Hiep edited this page Mar 22, 2023
·
2 revisions
Don't do this in an nginx Dockerfile
# CMD ["nginx", "-g", "daemon off;"] => NO, don't do this! 1. it is not neccessary and 2. it will disable the nginx template envsubst: https://github.com/nginxinc/docker-nginx/issues/422#issuecomment-644299743
https://www.baeldung.com/linux/nginx-config-environment-variables
CMD ["/bin/sh" , "-c" , "envsubst '$USER_NAME $PASSWORD $KEY' < /nginx.conf.template > /etc/nginx/nginx.conf && exec nginx -g 'daemon off;'"]
start.sh
#!/usr/bin/env bash
export DOLLAR='$'
envsubst < nginx.conf.template > /etc/nginx/nginx.conf
nginx -g "daemon off;"
proxy_set_header X-Forwarded-Host ${DOLLAR}host;