Normally, when Nginx
tries to read a certificate which does not exist, it will exit and throw an error.
Can I define any fall-back certificate in case the primary certificate does not exist?
Normally, when Nginx
tries to read a certificate which does not exist, it will exit and throw an error.
Can I define any fall-back certificate in case the primary certificate does not exist?
I have run into this same issue. I am deploying a docker cluster to production for which I want auto-generated SSL certificates. When SSL certs are in place, I want to force all traffic to redirect to https. It's not super glamorous, but this is the solution I came up with.
My nginx server has 2 config files: app.conf and tlsapp.conf
app.conf
tlsapp.conf
I then deploy my nginx container from a custom image.
nginx.Dockerfile
Lastly, my custom nginx image has a custom entrypoint in it. Basically all this entrypoint does is check to see if the ssl certificates have been created yet. If they have, it enables the tlsapp config and disables the config that was only in place to bootstrap in the certificates with certbot.
entrypoint.sh
This set up allows my nginx container to start in a new production environment when ssl certs haven't been generated. It provides certbot just enough access to generate the certificates into a shared persistent volume. Then all I have to do is redeploy the nginx container and it will start up, see the certificates, and enable my site's actual config that forces all traffic through https.
I don't love this setup cause it requires an awkward redeploy for a new production env and can be problematic if your set up is more complex than one app against one nginx server, but it works.
No. Why would your key not exist?