Skip to content

Generate Caddyfile

Zheng Luo edited this page Feb 16, 2018 · 2 revisions

Since 0.8.0, this project bundles a gen_caddyfile.sh along with a default template to generate Caddyfile from config.yaml, which could be directly used by Caddy web server.

Command-line usage

./gen_caddyfile.sh config.yaml outputCaddyfile

Before run, check if there is gomplate under the same directory with gen_caddyfile.sh

How it works

The template iterates over all repos, and check if it meets given requirements:

local repo

Condition worker has name and path

Effects Generate a route /{{name}} => {{path}}

reverse proxy

Condition worker has name and proxy_to

Effects Generate reverse proxy /{{name}} => {{proxy_to}}

Example

repos:
    - type: rsync
      source: rsync://rsync.chiark.greenend.org.uk/ftp/users/sgtatham/putty-website-mirror/
      interval: 6
      path: /tmp/putty
      name: putty # this will generate a route from /putty to /tmp/putty
    - type: external
      name: ubuntu
      proxy_to: http://ftp.sjtu.edu.cn/ubuntu/ # this will generate a route from /ubuntu to http://ftp.sjtu.edu.cn/ubuntu/

Additional routes

The bundled template will generate two additional routes:

/lug

lug JSON Restful API.

Reverse proxy to http://lug:7001

:9180/metrics

Prometheus metrics of Caddy server

Clone this wiki locally