Over time, my settings in default.conf are overwritten with the standard container settings
See original GitHub issueHello! I use jwilder/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion images for my system.
As the nginx-proxy configuration file, I use /opt/app/nginx_letsencript/conf.d/default.conf adding the necessary settings to me. For a while everything was fine, but I noticed that this file was overwritten with the default parameters and I can’t understand why. Comparing the overwrite time of default.conf with the entries in the jrcs/letsencrypt-nginx-proxy-companion container logs, I noticed that the certificates and default.conf were re-created, and the jwilder/nginx-proxy container was reloaded. But I can not understand the reasons for these actions or how I can avoid overwriting the file. Possible, am I missing something in the documentation for the jwilder/nginx-proxy image?
The logs of jrcs/letsencrypt-nginx-proxy-companion:
letsencrypt | /app
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
letsencrypt | 2020-02-15 15:58:48,497:INFO:simp_le:1546: Certificates already exist and renewal is not necessary, exiting with status code 1.
letsencrypt | /app
letsencrypt | Sleep for 3600s
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
letsencrypt | 2020-02-15 16:58:49,854:INFO:simp_le:1414: Generating new certificate private key
letsencrypt | 2020-02-15 16:58:56,335:INFO:simp_le:396: Saving key.pem
letsencrypt | 2020-02-15 16:58:56,335:INFO:simp_le:396: Saving fullchain.pem
letsencrypt | 2020-02-15 16:58:56,336:INFO:simp_le:396: Saving cert.pem
letsencrypt | /app
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
letsencrypt | 2020-02-15 16:58:57,060:INFO:simp_le:1546: Certificates already exist and renewal is not necessary, exiting with status code 1.
letsencrypt | /app
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
letsencrypt | 2020-02-15 16:58:57,729:INFO:simp_le:1546: Certificates already exist and renewal is not necessary, exiting with status code 1.
letsencrypt | /app
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
letsencrypt | 2020-02-15 16:58:58,483:INFO:simp_le:1546: Certificates already exist and renewal is not necessary, exiting with status code 1.
letsencrypt | /app
letsencrypt | Reloading nginx proxy (870451e160b9a99d72fe32b485dsdeww6ef7we6d40770e7abba51e5acef66c97)...
letsencrypt | 2020/02/15 16:58:59 Generated '/etc/nginx/conf.d/default.conf' from 7 containers
letsencrypt | 2020/02/15 16:58:59 [notice] 45#45: signal process started
letsencrypt | Sleep for 3600s
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
letsencrypt | 2020-02-15 17:58:59,798:INFO:simp_le:1546: Certificates already exist and renewal is not necessary, exiting with status code 1.
letsencrypt | /app
letsencrypt | /etc/nginx/certs/exemple.com /app
letsencrypt | Creating/renewal exemple.com certificates... (exemple.com)
My docker-compose.yml:
version: '3'
services:
service:
image: tl1-3/services:0.2
container_name: app
env_file:
- ./env/service.env
environment:
VIRTUAL_HOST=example.com
LETSENCRYPT_HOST=example.com
ports:
- "9999:9999"
restart: always
nginx-proxy:
image: jwilder/nginx-proxy
container_name: web
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: 'true'
volumes:
- ./nginx_letsencript/vhost.d:/etc/nginx/vhost.d
- ./nginx_letsencript/conf.d:/etc/nginx/conf.d
- ./nginx_letsencript/vhost.d/nginx.conf:/etc/nginx/nginx.conf
- ./nginx_letsencript/html:/usr/share/nginx/html
- ./nginx_letsencript/certs:/etc/nginx/certs
- ./service/public:/usr/src/app/public
- ./media:/usr/src/app/media
- /var/run/docker.sock:/tmp/docker.sock:rw
ports:
- "80:80"
- "443:443"
command: /bin/bash -c "nginx -g 'daemon off;'"
restart: always
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt
restart: always
volumes:
- ./nginx_letsencript/vhost.d:/etc/nginx/vhost.d
- ./nginx_letsencript/conf.d:/etc/nginx/conf.d
- ./nginx_letsencript/html:/usr/share/nginx/html
- ./nginx_letsencript/certs:/etc/nginx/certs
- /var/run/docker.sock:/var/run/docker.sock:rw
depends_on:
- nginx-proxy
privileged: true
restart: always
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
@newman0089 Yep. These features are implemented in the template file. E.g. the below instructs
docker-gen
to check if theexemple.com_location
file exists andinclude
it in the generated configuration file within the rootlocation
block.https://github.com/jwilder/nginx-proxy/blob/4a2dc46002a8464a07205756158da691afde13b7/nginx.tmpl#L325-L326
As per the documentation, you can have custom proxy-wide or per-
VIRTUAL_HOST
configurations:server_tokens off;
) in/etc/nginx/conf.d/custom.conf
.VIRTUAL_HOST
settings (e.g. additionallocation
blocks) within theserver
block in/etc/nginx/vhost.d/exemple.com
.VIRTUAL_HOST
settings (e.g.proxy_intercept_errors on;
) within thelocation
block in/etc/nginx/vhost.d/exemple.com_location
.All of the above depends on your exact nginx.tmpl template file. Furthermore, https://github.com/jwilder/nginx-proxy/pull/1179 may allow you to completely override the
location
blocks. Note that theupstream
directive is completely auto-generated by default based on theVIRTUAL_HOST
andVIRTUAL_PORT
environment variables set in the containers.If you cannot achieve what you want with the provided
nginx.tmpl
file, you might have to modify it to better suite your needs.