Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/drlogout/caddy-proxy
Automatic Caddy reverse proxy configurations for docker containers
https://github.com/drlogout/caddy-proxy
caddy caddyserver docker docker-gen letsencrypt proxy
Last synced: 5 days ago
JSON representation
Automatic Caddy reverse proxy configurations for docker containers
- Host: GitHub
- URL: https://github.com/drlogout/caddy-proxy
- Owner: drlogout
- Created: 2017-03-28T13:24:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-17T17:22:41.000Z (about 7 years ago)
- Last Synced: 2024-08-01T12:37:48.206Z (3 months ago)
- Topics: caddy, caddyserver, docker, docker-gen, letsencrypt, proxy
- Homepage:
- Size: 10.7 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
- awesome-starred - drlogout/caddy-proxy - Automatic Caddy reverse proxy configurations for docker containers (docker)
README
# caddy-proxy
caddy-proxy automatically generates [Caddy](https://caddyserver.com/) reverse proxy configurations for docker containers like [jwilder/nginx-proxy](https://github.com/jwilder/nginx-proxy) for Nginx.
## Usage
The template generation only works with docker-compose file version 2.
First, you'll need to create an external docker network named 'caddy-proxy'.
```bash
$ docker network create -d bridge caddy-proxy
```Then Clone this repository.
```bash
$ git clone https://github.com/drlogout/caddy-proxy
$ cd caddy-proxy
```Set a proper email address for `LETSENCRYPT_EMAIL` in `caddy/docker-compose.yml`.
```yaml
version: "2"networks:
proxy-tier:
external:
name: caddy-proxyservices:
caddy:
container_name: caddy
image: drlogout/caddy:0.9.5
# remove -ca=https://acme-staging.api.letsencrypt.org/directory in production
command: --conf /etc/caddy/config/Caddyfile --log stdout -ca=https://acme-staging.api.letsencrypt.org/directory
ports:
- 80:80
- 443:443
volumes:
- "../volumes/config:/etc/caddy/config"
- "../volumes/certs:/etc/caddy/certs"
environment:
- CADDYPATH=/etc/caddy/certs
networks:
- proxy-tier
restart: alwayscaddy-gen:
container_name: caddy-gen
image: jwilder/docker-gen:0.7.3
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "../volumes/templates:/etc/docker-gen/templates:ro"
volumes_from:
- caddy
environment:
LETSENCRYPT_EMAIL: ""
command: -notify "docker restart caddy" -watch -wait 5s:30s /etc/docker-gen/templates/caddy.tmpl /etc/caddy/config/Caddyfile
restart: always```
And start the `caddy` and `caddy-gen` containers.
```bash
$ cd caddy
$ docker-compose up -d
```Then set the `VIRTUAL_HOST` variable to a fully qualified domain name in `app1/docker-compose.yml` (resp. in `app2/docker-compose.yml`).
```yaml
version: "2"networks:
proxy-tier:
external:
name: caddy-proxyservices:
app1:
container_name: app1
image: httpd
networks:
- proxy-tier
environment:
VIRTUAL_HOST: ""
VIRTUAL_NETWORK: "caddy-proxy"
VIRTUAL_PORT: 80
restart: always```
And start the `app1` container (resp. `app2`).
```bash
$ cd ../app1
$ docker-compose up -d
```Please note, that this `caddy` configuration uses the [Letsencrypt staging environment](https://letsencrypt.org/docs/staging-environment/). This means your browser will warn you about an insecure connection. For use in production remove the `-ca=https://acme-staging.api.letsencrypt.org/directory` flag in `caddy/docker-compose.yaml`.