GithubHelp home page GithubHelp logo

rhtenhove / docker-environment Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 97 KB

Various docker containers for your everyday tasks

PHP 5.02% Shell 8.01% C 57.91% Python 29.05%
docker certbot haproxy agendav davical cyrus-sasl elk-stack maltego openssh python

docker-environment's Introduction

This repo is a collection of docker-compose definitions that I use throughout the day. They are based on many different sources of inspiration, and I hope they can be one of yours.

HTTPS

Haproxy handles SSL termination, and uses certificates generated by certbot and stored in the volume named letsencrypt

Obtaining Let's Encrypt certificates

Setting variables. Make sure you everything below in the same shell instance, since the variables will only available there. So if you need sudo for docker, first do sudo su.

FQDN=your domain
EMAIL=your e-mail address

Then we get a static IP address within the subnet of haproxy for the certbot container. Make sure haproxy is running and has an entry to redirect the http-01 challenge.

HAPROXYGATEWAY=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' haproxy)
CERTBOTIP=${HAPROXYGATEWAY/.1/.254}

The Hard Way

Generating a .csr with fancy new EC-crypto stuff. ed25519 will come later. Make sure your https clients support secp384r1 (for example check https://www.ssllabs.com/ssltest/viewMyClient.html)

docker run --rm -it -e FQDN \
-v letsencrypt:/etc/letsencrypt \
ubuntu:xenial \
bash -c "apt update && apt install openssl -y && \
openssl req -utf8 -nodes -sha512 -newkey ec:<(openssl ecparam -name secp384r1) -rand /dev/urandom -keyout /etc/letsencrypt/keys/$FQDN.key \
-out /etc/letsencrypt/csr/$FQDN.csr -subj '/C=/ST=/L=/O=/OU=/CN=$FQDN'"

Then we get the certificate

docker run --rm -e FQDN -e CERTBOTIP -e EMAIL \
-v letsencrypt:/etc/letsencrypt \
-v letsencryptvar:/var/lib/letsencrypt \
-v letsencryptlog:/var/log/letsencrypt \
--network="haproxy" \
--ip=$CERTBOTIP \
certbot/certbot \
certonly \
--csr /etc/letsencrypt/csr/$FQDN.csr \
--fullchain-path /etc/letsencrypt/csr/$FQDN.crt \
--standalone \
--preferred-challenges http-01 \
--agree-tos \
--no-eff-email \
-m $EMAIL \
-d $FQDN

Lastly, concatenate the key and fullchain into one file to be used by haproxy

docker run --rm -e FQDN -v letsencrypt:/etc/letsencrypt ubuntu:xenial bash -c "mkdir /etc/letsencrypt/haproxy ; cat /etc/letsencrypt/keys/$FQDN.key /etc/letsencrypt/csr/$FQDN.crt > /etc/letsencrypt/haproxy/$FQDN.pem" 

The Easy Way

Just getting an RSA key + certificate.

Make sure the FQDN actually points towards your haproxy instance

docker run --rm -e FQDN -e CERTBOTIP -e EMAIL \
-v letsencrypt:/etc/letsencrypt \
-v letsencryptvar:/var/lib/letsencrypt \
-v letsencryptlog:/var/log/letsencrypt \
--network="haproxy" \
--ip=$CERTBOTIP \
certbot/certbot \
certonly \
--standalone \
--preferred-challenges http-01 \
--agree-tos \
--no-eff-email \
-m $EMAIL \
-d $FQDN

Lastly, concatenate the key and fullchain into one file to be used by haproxy

docker run --rm -e FQDN -v letsencrypt:/etc/letsencrypt alpine:latest sh -c "mkdir /etc/letsencrypt/haproxy ; cat /etc/letsencrypt/live/$FQDN/privkey.pem /etc/letsencrypt/live/$FQDN/fullchain.pem > /etc/letsencrypt/haproxy/$FQDN.pem"

docker-environment's People

Contributors

rhtenhove avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

amauryvanespen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.