Background:
I am running an app inside Docker, that will be managed by random users that do often not have any knowledge about Docker itself. I am building the app to be as much configurable from the webserver itself as possible.
It runs 3 non-root containers:
- Container 1: Gunicorn,Django,Certbot
- Container 2: Nginx
- Container 3: Postgresql
I am able to let the Django app run certbot via the website itself to get a certificate and copy the certificate into the volume that nginx is using. But the old or self-signed certificate seems to be cached by nginx on startup and so the new certificate is not used until a restart of nginx.
And here is the problem, I must now restart nginx or somehow reload the certificates automatically. Either by triggering the restart from the Django container to the Nginx Container maybe via a curl or something. Or I can use something like watchdog to watch the files for a file change.
Question:
What is the best approach to reload nginx automatically if a certificate changes? Or can I purge the certificate cache of the certificates even without restarting the server? What is your suggestion here?
Thanks for your help in advance!