DEV Community

Cover image for Manage a multiple websites server with Docker Compose, NGINX and auto SSL certificates

Posted on

Manage a multiple websites server with Docker Compose, NGINX and auto SSL certificates

After my last post about deploying a Vue application on Clever Cloud, I have been thinking to manage a server and deploy all my side projects on it. The goal was to:

  • set up a reverse proxy easily
  • automatically generate/renew the SSL certificates (let's encrypt)
  • few simple configurations

One project caught my eye on Github:

GitHub logo evertramos / nginx-proxy-automation

Automated docker nginx proxy integrated with letsencrypt.

The project creates a production environment in a few seconds. Everything is containerized. By looking at the docker-compose.yml, the environment is based on 3 main containers:

  • nginx-web: NGINX reverse proxy server and web server, it distributes requests to the corresponding container.
  • nginx-gen: It generates the vhost configurations and detects if running containers are started or stopped to reloads NGINX.
  • nginx-letsencrypt: Automated creation/renewal of Let's Encrypt certificates

Here is a simplified schema:

docker compose letsencrypt nginx proxy schema

The setup is straightforward to understand, just clone the project and copy the example Dotenv file with a custom configuration. Finally, execute the script to pull the images and run the containers.

To make an application available on the web, the container has to be connected to the webproxy network and needs 3 environment variables:
Enter fullscreen mode Exit fullscreen mode

Configure the DNS provider to point to the server IP. Start the container and that's it! Visit the web application at the specified domain name.

As an example, the following projects can be created in few second:


The project docker-compose-letsencrypt-nginx-proxy-companion is maybe not the best option for a big production with hundreds of thousands of users (I have never tried). Nevertheless, it is working perfectly for small applications. It is easy to set up and trustworthy. A small community is available and the creator is reactive on Github.

For now, this project is a good solution for me to serve all my projects on the web at a low cost. I'm pretty happy to use it!

How do you manage your server and projects?

Thanks for reading!

Top comments (7)

heyeasley profile image
heyeasley πŸ“πŸ₯­

Brilliant. When managing both websites servers, will their latencies remain affected or not ?

steeve profile image

Thanks @heyeasley. Treafik doesn't add latency. the latency only depends on your server location. If it is located far from your client, it would take a longer time to reach and download.

heyeasley profile image
heyeasley πŸ“πŸ₯­


dennislwm profile image
dennislwm • Edited

Good article. I have done something similar to you, but with Terraform-Docker-Compose-Caddy-LetsEncrypt.
Terraform is β€œinfrastructure as code” used to deploy resources instantly on cloud engines.
Docker-compose is β€œcontainerized” apps running on these resources.
Caddy is used to automate reverse-proxy on HTTPS.
Terraform is great for scaling resources up or down with minimal server downtime. Creating a side project is literally just copy and paste a module in Terraform. Regards.

steeve profile image

The main issue of the project I'm using is the scaling, I don't find a quick solution. I will try your project and the technologies you are sharing with me.
Thank you, I appreciate your comment!

jrc86 profile image

Thanks :)

steeve profile image

You are welcome Jonas πŸ‘