How to use Let's Encrypt with Docker container based on the Node.js image

前端 未结 5 813
时光说笑
时光说笑 2020-12-23 22:17

I am running an Express-based website in a Docker container based on the Node.js image. How do I use Let\'s Encrypt with a container based on that image?

5条回答
  •  太阳男子
    2020-12-23 22:43

    You may have a look here : https://certbot.eff.org/docs/using.html?highlight=docker#running-with-docker

    Then what I personally do is :

    1. Create a Docker volume to store the certs and generate the certs with the above image
    2. Create a Docker user-defined network (https://docs.docker.com/engine/userguide/networking/#/user-defined-networks)
    3. Create an image based on nginx with your configuration (maybe this will be useful)
    4. Create a Nginx container based on your image, mount the volume in it and connect it to the network (also forward port 80 and 443 to whatever you want)
    5. I would create a container for your node.js app and connect it to the same network

    Now if you configured nginx correctly (point to the right path for the TLS certs and proxy to the right URL, like http://my-app:3210) you should have access to your app in https.

提交回复
热议问题