docker – nginx: [emerg] invalid variable name
I’m having a problem using an environment variable in nginx.conf using docker-compose and dockerFile
I get the following error:
nginx: [emerg] invalid variable name in /etc/nginx/nginx.conf:291
The problem line:
set_hmac_sha1 $sig "$SECRET_KEY" "$cookie_sessionid $stream_username";
My dockerFile sets SECRET KEY the following way —>
Environment variable for re-authorization:
ENV SECRET_KEY=${SECRET_KEY}
My docker-compose links to:
env_file:
- .docker-compose.env
My .docker-compose.env file finally defines the SECRET_KEY variable:
SECRET_KEY= "this is the Django secret_key"
I have an entrypoint.sh which I use has the following 2 lines at the bottom one of them which is the envsubst:
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < \
/etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
nginx -g 'daemon off;'
Also, maybe just for mentioning it–>
I Copy the custom nginx.conf to the container:
COPY nginx.conf /etc/nginx/nginx.conf.template
Read more here: Source link
