-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathCaddyfile
60 lines (53 loc) · 2.65 KB
/
Caddyfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Redirect caddyfile for processing systemd-sysupdate requests.
#
# This Caddyfile will redirect incoming requests to GitHub releases, making it appear to clients like systemd-sysupdate
# as if all sysexts # released on the Bakery are in the same directory.
# For clients, the directory layout looks like e.g.:
#
# SHA256SUMS
# kubernetes-v1.28.2-amd64.raw
# kubernetes-v1.28.2-arm64.raw
# kubernetes-v1.28.4-amd64.raw
# kubernetes-v1.28.4-arm64.raw
# kubernetes-v1.29.1-amd64.raw
# kubernetes-v1.29.1-arm64.raw
# ...
#
# while in fact requests are being redirected to GitHub releases depending on which pattern matches the request.
# For testing locally, uncomment the below and comment 'extensions.flatcar.org {',
# then run
# docker run --rm -ti -v ${PWD}/Caddyfile:/etc/caddy/Caddyfile -p 8080:80 caddy
#:80 {
extensions.flatcar.org {
vars base_dest_url "https://github.com/flatcar/sysext-bakery/releases/download"
# Extension image.
# <extension>-<version>-<arch>.raw
# ==> https://[...]/releases/download/<extension>-<version>/<extension>-<version>-<arch>.raw
# Match groups: 1 - extension, 2 - version, 3 - arch
@raw path_regexp raw ^.*/extensions/([^/]+)-([^/]+)-(x86-64|arm64).raw$
redir @raw {vars.base_dest_url}/{re.raw.1}-{re.raw.2}/{re.raw.1}-{re.raw.2}-{re.raw.3}.raw
# Sysupdate conf. This is only used by Ignition.
# <extension>-<version>.conf
# ==> https://[...]/releases/download/<extension>-<version>/<extension>-<version>.conf
# Match groups: 1 - extension, 2 - version
@conf path_regexp conf ^.*/extensions/([^/]+).conf$
redir @conf {vars.base_dest_url}/{re.conf.1}/{re.conf.1}.conf
# Sysupdate or extension image with explicit release sub-path.
# /<release>/<extension-conf-or-raw>
# ==> https://[...]/releases/download/<release>/<extension-conf-or-raw>
# Match groups: 1 - release, 2 - filename, 3 - suffix
@expl path_regexp expl ^.*/extensions/([^/]+)/([^/]+).(conf|raw)$
redir @expl {vars.base_dest_url}/{re.expl.1}/{re.expl.2}.{re.expl.3}
# Extension specific SHA file with extension name in path (group 1)
# <extension>/SHA256SUMS
# ==> https://[...]/releases/download/<extension>/SHA256SUMS
@esha path_regexp esha ^/extensions/([^/]+)/SHA256SUMS$
redir @esha {vars.base_dest_url}/{re.esha.1}/SHA256SUMS
# Global SHA file with all extensions in it.
# /SHA256SUMS
# ==> https://[...]/releases/download/SHA256SUMS/SHA256SUMS
@sha path_regexp sha ^/extensions/SHA256SUMS$
redir @sha {vars.base_dest_url}/SHA256SUMS/SHA256SUMS
# None of the above matched, redirect to the website.
redir https://flatcar.github.io/sysext-bakery{uri}
}