Enabling SSL with Let’s Encrypt, NGINX and Docker

Recently, I read a lot of articles on how to enable ssl with certbot, nginx and docker, but all the methods I read did not work for me untill I found this methods listed below. Thanks to all the authories who wrote the articles in the references.

Steps

  • Setting up Nginx and Certbot on your host server
  • Obtaining an SSL Certificate on your hose server
  • Map your host letsencrypt folder to nginx in docker

Detail

Step 1 Setting up Nginx and Certbot on your host server

Setting up Nginx

find the following line:

change to your domain name

reload your nginx new configuration

Step 2 Obtaining an SSL Certificate

You need to configure your HTTPS settings according to certbot.

After you configure your HTTPS, stop the nginx

Step 3 Map your host letsencrypt folder to nginx in docker

You'd like to modify your nignx config file first.

Then you need to open 443 port and map folders to docker.

Here is a sample.

Conclusion

I knew this approach is not elegant, but it works.

References

如何免费的让网站启用HTTPS

How To Secure Nginx with Let's Encrypt on Ubuntu 14.04

Enabling SSL with Let's Encrypt, NGINX and Docker

stackoverflow

Leave a Reply

Your email address will not be published. Required fields are marked *