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

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

steeve profile image Steeve ・2 min read

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 / docker-compose-letsencrypt-nginx-proxy-companion

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 start.sh 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:

VIRTUAL_HOST=your.domain.com
LETSENCRYPT_HOST=your.domain.com
LETSENCRYPT_EMAIL=your.email@your.domain.com

Configure the DNS provider to point your.domain.com 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:

Conclusion

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!

Posted on by:

steeve profile

Steeve

@steeve

R&D Developer @Easilys & @CarboneJS. If you’re interested in grabbing a coffee and talking, please contact me !

Discussion

pic
Editor guide
 

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.
URL: github.com/dennislwm/dscode

 

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!

 
 

You are welcome Jonas 👏