Config using environment variables
Currently the only way to set a global or per-vhost config is to mount a corresponding conf file into nginx container. Even though it can be done via creating custom container or mounting a volume with config files, using env vars would be more easy and effortless. My proposition is as follows:
At startup, scan all env vars starting with NGINX_* and add corresponding entries to /etc/nginx/conf.d/environment.conf and for each vhost do the same for hosts env vars. This way we would avoid hardcoding and maintaining an array of possible env variable names. Example usage from docker-compose:
services:
nginx:
image: jwilder/nginx-proxy
environment:
NGINX_CLIENT_MAX_BODY_SIZE: 30M
ports:
- 80:80
...
app:
image: app
environment:
VIRTUAL_HOST: example.com
NGINX_ACCESS_LOG: 'off'
or from the command line:
docker run -d -p 80:80 -e NGINX_CLIENT_MAX_BODY_SIZE=30M ... jwilder/nginx-proxy
There are 2 related issues #597 and #688 but they are a few years old and unanswered.
Is there interest for implementing this? I can try to do it. Maybe a similar solution already exists?
Or is it a bad idea? If so, why?
I've made a simple wrapper that adds env variables to global config using a shell script https://github.com/poma/docker-gen
Need this
Any update?