Last active
May 30, 2018 07:23
-
-
Save Ocramius/d2d6a1fae973abd70a307383ed36ef22 to your computer and use it in GitHub Desktop.
Example of Caddy in front of an HTTP server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{$CADDY_WEB_HOST}:443 { | |
proxy / the-webserver.internal-network:80 | |
tls self_signed | |
} | |
{$CADDY_WEB_HOST}:80 { | |
redir https://{$CADDY_WEB_HOST}{uri} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
export CADDY_WEB_HOST=my-domain.com | |
export [email protected] | |
docker-compose up -d --build --force-recreate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM abiosoft/caddy:0.10.11 | |
ADD Caddyfile /etc/Caddyfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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