-
Notifications
You must be signed in to change notification settings - Fork 1
/
Caddyfile
38 lines (33 loc) · 1005 Bytes
/
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
{
order cache before rewrite
cache
}
{$ADDRESS:*} {
# If REGISTRY_ORG is set, limit requests to that path:
map {$REGISTRY_ORG:""} {path_matcher} {
~.+ {$REGISTRY_ORG}/*
default *
}
@api_request {
path /v2/
path /v2/{path_matcher}
}
route @api_request {
redir https://{$REGISTRY_HOST}{uri} 307
# These responses are all constant redirects, except if we actually change to a
# completely different registry. Cache them for 1 day, so that clients & downstream
# proxies can avoid fully duplicating basic requests here, so far as possible.
cache {
ttl {$CACHE_TIMEOUT:86400}s
default_cache_control max-age={$CACHE_TIMEOUT:86400}, must-revalidate
key {
hide
}
}
}
route * {
respond 403 {
body `{ "errors": [{"message": "Only API requests for {path_matcher} images are supported"}] }`
}
}
}