LetsEncrypt SSL certificate (re) issuer for other containers
3.8K
jwilder/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion only.Here is the example docker-compose.yml
version: '2.2'
services:
nginx-proxy:
container_name: nginx-proxy
image: jwilder/nginx-proxy
restart: unless-stopped
ports:
- 80:80/tcp
- 443:443/tcp
volumes:
- ./nginx-proxy/certs:/etc/nginx/certs
- ./nginx-proxy/conf.d:/etc/nginx/conf.d
- ./nginx-proxy/html:/usr/share/nginx/html
- ./nginx-proxy/htpasswd:/etc/nginx/htpasswd
- ./nginx-proxy/vhost.d:/etc/nginx/vhost.d
- ./nginx-proxy/dhparam.pem:/etc/nginx/dhparam/dhparam.pem
- ./nginx-proxy/logs:/var/log/nginx
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- example
nginx-proxy-le:
container_name: nginx-proxy-le
image: jrcs/letsencrypt-nginx-proxy-companion
restart: unless-stopped
environment:
- "NGINX_PROXY_CONTAINER=nginx-proxy"
- "[email protected]"
volumes:
- ./nginx-proxy/acme.sh:/etc/acme.sh
- ./nginx-proxy/certs:/etc/nginx/certs
- ./nginx-proxy/vhost.d:/etc/nginx/vhost.d
- ./nginx-proxy/html:/usr/share/nginx/html
- /etc/localtime:/etc/localtime
- /etc/timezone:/etc/timezone
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- example
strongswan-le:
container_name: strongswan-le
image: robonuka/le-cert-issuer
restart: unless-stopped
init: true
depends_on:
- nginx-proxy-le
expose:
- 80/tcp
environment:
- "VIRTUAL_HOST=vpn.example.com"
- "VIRTUAL_PORT=80"
- "LETSENCRYPT_HOST=vpn.example.com"
- "[email protected]"
- "LETSENCRYPT_RESTART_CONTAINER=true"
- "SLAVE_CONTAINER_NAME=strongswan"
- "DOCKER_SOCKET_FILE=/tmp/docker.sock"
volumes:
- /etc/localtime:/etc/localtime
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- example
strongswan:
container_name: strongswan
image: robonuka/strongswan:5.9.4
restart: unless-stopped
init: true
network_mode: "host"
privileged: true
cap_add:
- NET_ADMIN
- SYS_MODULE
- SYS_ADMIN
environment:
- "SERVER_HOSTNAME=vpn.example.com"
- "SERVER_IP=<your.host.ip.address>"
- "SERVER_SUBNET=<internal_net/cidrmask>"
- "CLIENT_SUBNET=<vpnclient_subnet/cidrmask>"
- "CLIENT_DNS=77.88.8.8,1.1.1.1"
- "CHARONDEBUG=dmn -1, mgr -1, ike 1, chd -1, job -1, cfg -1, knl -1, net 1, asn -1, enc -1, lib -1, esp -1, tls -1, tnc -1, imc -1, imv -1, pts -1"
- "USERS=user:password"
volumes:
- /etc/localtime:/etc/localtime
- /lib/modules:/lib/modules:ro
- ./nginx-proxy/certs/vpn.example.com/chain.pem:/etc/ipsec.d/cacerts/ca.pem:ro
- ./nginx-proxy/certs/vpn.example.com/cert.pem:/etc/ipsec.d/certs/certificate.pem:ro
- ./nginx-proxy/certs/vpn.example.com/key.pem:/etc/ipsec.d/private/key.pem:ro
- ./strongswan:/mnt
networks:
example:
driver: "bridge"
In this example container strongswan-le will issue/reissue Letsencrypt SSL certificate for the strongswan container and if this is happens it will restart strongswan container (because environment variable "SLAVE_CONTAINER_NAME=strongswan" has been defined)
Before the first run you should prepare all folders and files needed for containers:
mkdir -p /opt/nginx-proxy/{acme.sh,certs,conf.d,html,htpasswd,logs,vhost.d}
openssl dhparam -out /opt/nginx-proxy/dhparam.pem 2048
And then do the first run:
docker-compose up -d nginx-proxy nginx-proxy-le
wait 5-10 sec, then check that nginx-proxy and nginx-proxy-le containers are up and running, then do:
docker-compose up -d strongswan-le
If you run docker logs -f nginx-proxy-le you can see issuing SSL cetrificate process in realtime
If SSL certificate issued successfully you can run strongswan container:
docker-compose up -d strongswan
That's it.
Since now issuing/reissuing Letsencript SSL certificate for your IPSecVPN server will be fully automatic.
More details about Strongswan container setup you can see here:
https://hub.docker.com/repository/docker/robonuka/strongswan
Content type
Image
Digest
sha256:33035787f…
Size
72.9 MB
Last updated
6 days ago
docker pull robonuka/le-cert-issuer