Cover image for Dockerise your Nuxt SSR App like a boss! (A True Vue Vixens story) [Part 2]
Front-End Foxes

Dockerise your Nuxt SSR App like a boss! (A True Vue Vixens story) [Part 2]

superdiana profile image Super Diana Updated on ・2 min read

Intro 💅

As i promised before, the next part of this series of tutorials, is about adding a SSL certificate container to your stack. Let's get it started! (yeah!).

Hands on 👋🏼

We are going to use an existing Docker image of Let's Encrypt to generate the key files, and in order for the certificates generated to be used in the nginx container we have to create a directory in our host to use them as a gateway between both containers.

Let's create the directory we are going to use as gateway: (in my case my local folder is website so, right in the same folder)

mkdir -p -m 755 website/etc/letsencrypt

Stop the containers we created before. We need to stop the containers because the container of Certbot will be using ports 80 and 443.

docker-compose stop

Now we are able to create the certs using a docker image. You may check the project in Github https://github.com/pierreprinetti/certbot

In your terminal run:

docker run -v /etc/letsencrypt:/etc/letsencrypt \
-e http_proxy=$http_proxy \
-e domains="example.com" \
-e email="firstName.lastName@example.com" \
-p 80:80 -p 443:443 \
--rm pierreprinetti/certbot:latest

Then we need to make some changes in the nginx configuration to be able to use the port and cert files. Open the nginx.conf file in our nginx folder and add:

server {
    listen 443 http2;
    listen [::]:443 http2;
    server_name yourdomain.com; ## Use your domain name
    ssl on;
    ssl_certificate /etc/nginx/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/letsencrypt/live/yourdomain.com/privkey.pem;

Now, let's add the Let's Encrypt certs folder as a volume in our docker-compose file:

    image: nginx:latest
    container_name: vuevixens-nginx
      - "80:80"
      - "443:443"
      - ./nginx:/etc/nginx/conf.d
      - /etc/letsencrypt:/etc/letsencrypt
      - nuxt

We are almost ready to roll!, now we need to run docker-compose to update to the latest changes!:

docker-compose up -d

Then that's all the needed, and once the container is running you'll have SSL on your website!!!


The next part of this series will include adding portainer to access our logs, monitor our containers and lots of exciting features for Docker through a Web UI.

Spread the love!! -- A big shoutout to Luis Alfredo Chee for his magic!


Editor guide
sgraewe profile image
Stefan Gräwe

awesome, thank you :)

steeve profile image

Thanks it's perfect 👏

mannuelf profile image

Thanks for sharing, I learnt a lot. 🚀

denisinvader profile image
Mikhail Panichev

Why do you need an SSL certificate into a Docker container? You deploy containers on some server and on this server you can just make Nginx proxy (with SSL support) to any running container.

superdiana profile image
Super Diana Author

There are a zillion ways to do it. This a series of articles to show different approaches.

Let's keep the space mansplaining free 😁