cloudserve-infrastructure/roles/caddy
Marty Oehme f4864c5da3
Fix caddy container info delay
Give more time to docker to correctly bring up caddy in the swarm.
Extended delay to retry to 10 seconds and gave it more retries as well,
so that roughly a minute will be gone before the play gives up.
2021-10-20 17:33:35 +02:00
..
defaults Switch caddy to use json configuration 2021-07-31 17:26:06 +02:00
meta Add basic caddy swarm role 2021-07-29 14:39:43 +02:00
tasks Fix caddy container info delay 2021-10-20 17:33:35 +02:00
templates Switch caddy to use json configuration 2021-07-31 17:26:06 +02:00
vars Switch caddy to use json configuration 2021-07-31 17:26:06 +02:00
README.md Add caddy README 2021-08-01 09:38:41 +02:00

Caddy

Caddy is the reverse proxy for all other services running on the infrastructure. It was chosen for its relative ease of use, interactible API and https-by-default setup.

Variables

caddy_caddyfile_dir: "{{ docker_stack_files_dir }}/caddy"

Sets up the on-target directory where important caddy files should be stored.

caddy_email: <your@email.here>

Which e-mail should be used to provision https certificates with. I believe theoretically caddy will work and provision you with certificates even without providing an e-mail, but I would strongly urge providing one.

caddy_tls_use_staging: no

If turned on will use the staging servers of the acme certificate service, which is useful for testing and playing around with https (due to higher API limits and less severe restrictions).

caddy_use_api: yes

If turned off, will turn off the admin api for caddy. Should only be used if no other services are intended to be provisioned on the target, since most other service stacks rely on the API to set up their proxy targets.

caddy_use_debug: no

If true, will turn on caddy's debug logging.

caddy_use_https: yes

If turned off will turn of all auto-provisioning of https certificates by caddy.

caddy_version: alpine

Sets the docker image version to be used.

Internal variables

caddy_stack:
    name: caddy
    compose: "{{ lookup('template', 'docker-stack.yml.j2') | from_yaml }}"

Defines the actual docker stack which will later run on the target. The name can be changed and will be used as a proxy target (caddy.mydomain.com or 192.168.1.1/caddy) --- though to be clear there is no intention currently to expose the caddy to the web at the moment.
The compose option defines which template to use for the docker-stack.yml file. You can either change options for the stack in the template file, or directly here like the following:

    compose: 
      - "{{ lookup('template', 'docker-stack.yml.j2') | from_yaml }}"
      - version: '3'
        services:
          another-container:
            image: nginx:latest
#           ...
caddy_http_server_name: http
caddy_https_server_name: https

The internal representation of the http and https servers respectively.