Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Last active May 30, 2018 07:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ocramius/d2d6a1fae973abd70a307383ed36ef22 to your computer and use it in GitHub Desktop.
Save Ocramius/d2d6a1fae973abd70a307383ed36ef22 to your computer and use it in GitHub Desktop.
Example of Caddy in front of an HTTP server
{$CADDY_WEB_HOST}:443 {
proxy / the-webserver.internal-network:80
tls self_signed
}
{$CADDY_WEB_HOST}:80 {
redir https://{$CADDY_WEB_HOST}{uri}
}
version: '3'
services:
the-webserver:
build:
context: .
dockerfile: the-webserver-Dockerfile
hostname: "the-webserver"
restart: unless-stopped
networks:
the-internal-network:
aliases:
- "the-webserver.internal-network"
the-gateway:
build:
context: .
dockerfile: the-gateway-Dockerfile
volumes:
- caddy-certificate-volume:/root/.caddy
hostname: "the-gateway"
depends_on:
- "the-webserver"
ports:
- "80:80"
- "443:443"
environment:
- "CADDY_TLS_EMAIL"
- "CADDY_WEB_HOST"
restart: unless-stopped
networks:
the-internal-network:
the-public-network:
networks:
the-internal-network:
internal: true
the-public-network:
volumes:
caddy-certificate-volume:
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
export CADDY_WEB_HOST=my-domain.com
export CADDY_TLS_EMAIL=hello@my-domain.com
docker-compose up -d --build --force-recreate
FROM abiosoft/caddy:0.10.11
ADD Caddyfile /etc/Caddyfile
FROM nginx:latest
# set up your nginx to listen to port 80 here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment