PavelHudau / lets-haproxy

Configuration to make Let's Encrypt and HAProxy work together in Docker and automatically renew SSL certificates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lets-haproxy

A configuration which you can use to run a web-application + APIs behind HAProxy with Let's Encrypt and automatically renewed SSL certificates.

HAProxy, Let's Encrypt certbot and your Application(s) are run as Docker containers with Docker Compose. Therefore entire configuration is easy portable to any cloud. Almost everything is automated, so there are just a few manual steps you need to make.

diagram

Application

You need to deploy an App available on the web and your criterial are:

  1. HTTPS for security.
  2. Minimize vendor lock on cloud providers, so you can easily move to other cloud.
  3. Minimize hosting cost, e.g. have just 1 Virtual Machine (e.g. Amazon EC2).
  4. Have 1 or more pieces of your web-app (e.g. website + APIs service(s)) running behind a proxy with SSL.

Advantages:

  1. HAProxy takes care about HTTPS part. Your web-application can just talk plain HTTP.
  2. All components are Docker images, so thereare no other dependencies to configure.
  3. Deployment is done with docker-compose, so no need to configure ports / networks / files.
  4. All steps are scripted. There are minimum manul things left to do.

Pre-requisites:

  1. letsencrypt folder with initial certificates. Here is a nice article which shows how to get it. (It's also possible to do with just lets-certbot and lets-haproxy Docker images)
  2. Docker
  3. Docker Compose

Steps:

  1. build and run cookiecutter. cookiecutter will generate your scripts. Follow cookiecutter instruction and you will get all scripts in seconds.
    # Builds cookiecutter docker image
    ./build.sh
    # Run cookiecutter docker container to generate lets-haproxy scripts
    ./run.sh
  2. Go to newly generated scripts folder output. The folder contains all scripts you would need to run and a sample react app.
    cd output\{{directory_name you provided to cookiecutter}}
    let-haproxy documentation / instructions can be found at output\{{directory_name you provided to cookiecutter}}\README

About

Configuration to make Let's Encrypt and HAProxy work together in Docker and automatically renew SSL certificates

License:MIT License


Languages

Language:Shell 54.7%Language:TypeScript 25.7%Language:Dockerfile 9.9%Language:HTML 6.3%Language:CSS 3.4%