项目作者: whitestrake

项目描述 :
Automated reverse proxying of Docker containers via Caddy & docker-gen
高级语言: Shell
项目地址: git://github.com/whitestrake/caddy-gen.git
创建时间: 2017-10-12T06:13:18Z
项目社区:https://github.com/whitestrake/caddy-gen

开源协议:

下载


caddy-gen

Traefik-like reverse proxying based on:

First run caddy-gen, via compose:

  1. caddy-gen:
  2. image: whitestrake/caddy-gen
  3. volumes:
  4. - /path/to/certs:/root/.caddy
  5. - /var/run/docker.sock:/var/run/docker.sock
  6. ports:
  7. - 80:80/tcp
  8. - 443:443/tcp

The first mount preserves LetsEncrypt certificates in the folder /path/to/certs on your Docker host. The second mount allows docker-gen to monitor Docker for container changes.

Next, include some env vars in your other services to tell docker-gen to include them in the proxy configuration:

  1. whoami:
  2. image: emilevauge/whoami:latest
  3. environment:
  4. CADDY_HOST: "whoami.example.com"
  5. CADDY_PROXY_PARAMS: "transparent,websocket"
  6. CADDY_BASIC_AUTH: "/:foo:bar,/dir:user:badpassword"

As long as your server is accessible at whoami.example.com, you’ll be up and running with HTTPS in seconds.

Environmental variables:

Set these on any container you want proxied.

Variable Description
CADDY_HOST Required; tells Caddy what to use as a site label when reverse proxying your container.
CADDY_DISABLE_TLS Optional; if set to any value, Caddy will serve your site at port 2015 instead of configuring HTTPS.
CADDY_BASIC_AUTH Optional; takes the format [path]:[user]:[pass], where [path] is the directory to protect. Declare multiple by separating them with commas.
CADDY_PROXY_PARAMS Optional; a comma-separated list of subdirectives for the proxy directive, such as transparent or websocket; see http.proxy.