I'm running into a bit of a catch-22 while setting up NGINX with SSL certificates in Docker. I have a Node.js server on port 3000, and I want to set up NGINX in another Docker container to act as a reverse proxy for it. The problem is that my NGINX configuration needs SSL certificates to set up HTTPS and redirect from HTTP, but Let's Encrypt requires NGINX to be running to issue those certificates. How can I break this loop in my Docker setup?
3 Answers
You can start by setting up NGINX to listen on port 80 first. Then, run Let's Encrypt. It'll automatically configure port 443 and set up the redirect from port 80 to 443 for you, solving the issue a lot more seamlessly!
What you can do is run NGINX initially without any SSL settings. Use Certbot to get your certificate, and then update your NGINX virtual host configuration to include SSL with the newly obtained certificate. If you're looking for an easier option, you might want to consider using a Docker reverse proxy like Caddy or Traefik, as they'll handle SSL automation for you!
Just a quick thought—does Certbot work well with NGINX when both are set up inside Docker?
So, I need to prepare an NGINX config without SSL first, launch the container, then run a Certbot container, and after that, I can update the NGINX config with SSL? That's quite the process!