question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Over time, my settings in default.conf are overwritten with the standard container settings

See original GitHub issue

Hello! 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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
sgabecommented, Feb 19, 2020

@newman0089 Yep. These features are implemented in the template file. E.g. the below instructs docker-gen to check if the exemple.com_location file exists and include it in the generated configuration file within the root location block.

https://github.com/jwilder/nginx-proxy/blob/4a2dc46002a8464a07205756158da691afde13b7/nginx.tmpl#L325-L326

2reactions
sgabecommented, Feb 18, 2020

As per the documentation, you can have custom proxy-wide or per-VIRTUAL_HOST configurations:

  • You could specify custom proxy-wide settings (e.g. server_tokens off;) in /etc/nginx/conf.d/custom.conf.
  • You could specify custom per-VIRTUAL_HOST settings (e.g. additional location blocks) within the server block in /etc/nginx/vhost.d/exemple.com.
  • You could specify custom per-VIRTUAL_HOST settings (e.g. proxy_intercept_errors on;) within the location 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 the upstream directive is completely auto-generated by default based on the VIRTUAL_HOST and VIRTUAL_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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Over time, my settings in default.conf are overwritten ... - GitHub
Hello! I use jwilder/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion images for my system. As the nginx-proxy configuration file, ...
Read more >
Nginx config file overwritten during Elastic Beanstalk ...
Create my version of the nginx config file. Create a script to overwrite the standard config file with my own. Run the script....
Read more >
Store configuration data using Docker Configs
Create a redis service and grant it access to the config. By default, the container can access the config at /my-config , but...
Read more >
config.xml is overwritten on first start of docker container
After starting my container, I can see my config. xml in /var/jenkins_home for a couple of seconds. After that, it is overwritten with...
Read more >
Settings file keep being overwritten : r/docker - Reddit
I stop the docker, edit the settings file, and then after starting the container the settings file is back to the default. What...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found