Heavily inspired by wemake-services' awesome caddy-gen.
Use labels.
The main idea is simple. Every labeled service exposes a virtual.host to be handled. Then, every container represents a single reverse_proxy's to option to serve requests.
Options to configure:
virtual.hostdomain name, don't passhttp://orhttps://, you can separate them with space,virtual.aliasdomain alias, e.q.wwwprefix,virtual.portport exposed by container, e.g.3000for React apps in development,virtual.tls-emailthe email address to use for the ACME account managing the site's certificates,virtual.host.directivesset custom Caddyfile directives for the host. These will be inlined into the site block.virtual.host.importinclude Caddyfile directives for the host from a file on the container's filesystem. See Caddy import.virtual.proxy.matcherhave the reverse proxy only match certain paths.virtual.proxy.lb_policyspecify load balancer policy, defaults to round_robin.virtual.proxy.directivesinclude any reverse_proxy directives. These will be inlined into the reverse proxy block.virtual.proxy.importinclude any reverse_proxy directives from a file on the container's filesystem. See Caddy import.virtual.auth.usernameandvirtual.auth.passwordtogether provide HTTP basic authentication.
Password should be a string base64 encoded from bcrypt hash. You can use https://bcrypt-generator.com/ with default config and https://www.base64encode.org/.
To backup certificates make a volume:
./caddy-info:/data/caddy