-
Notifications
You must be signed in to change notification settings - Fork 1
/
Caddyfile
201 lines (174 loc) · 7.61 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
{
auto_https {$HTTPS}
}
docker.{$DOMAIN}:{$PORT} {
handle_path /docker-production-cloudflare/* {
reverse_proxy https://production.cloudflare.docker.com {
header_up Host production.cloudflare.docker.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie production.cloudflare.docker.com docker.{$DOMAIN}
}
}
handle_path /docker-token/* {
reverse_proxy https://auth.docker.io {
header_up Host auth.docker.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie auth.docker.io docker.{$DOMAIN}
}
}
@docker {
header_regexp User-Agent docker
}
handle @docker {
reverse_proxy * https://registry-1.docker.io {
header_up Host registry-1.docker.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie registry-1.docker.io docker.{$DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://docker.{$DOMAIN}/docker-token/token\",service=\"registry.docker.io\""
header_down Location "https://production.cloudflare.docker.com" "https://docker.{$DOMAIN}/docker-production-cloudflare"
}
}
}
gcr.{$DOMAIN}:{$PORT} {
@docker {
header_regexp User-Agent docker
}
handle @docker {
reverse_proxy * https://gcr.io {
header_up Host gcr.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie gcr.io gcr.{$DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://gcr.{$DOMAIN}/v2/token\",service=\"gcr.io\""
}
}
}
ghcr.{$DOMAIN}:{$PORT} {
@docker {
header_regexp User-Agent docker
}
handle @docker {
reverse_proxy * https://ghcr.io {
header_up Host ghcr.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie ghcr.io ghcr.{$DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://ghcr.{$DOMAIN}/token\",service=\"ghcr.io\""
}
}
}
quay.{$DOMAIN}:{$PORT} {
@docker {
header_regexp User-Agent docker
}
handle @docker {
reverse_proxy * https://quay.io {
header_up Host quay.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie quay.io quay.{$DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://quay.{$DOMAIN}/v2/auth\",service=\"quay.io\""
}
}
}
k8s-io.{$DOMAIN}:{$PORT} {
handle_path /dev/* {
reverse_proxy * https://us-west1-docker.pkg.dev {
header_up Host us-west1-docker.pkg.dev
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_down Set-Cookie us-west1-docker.pkg.dev k8s-io.{$DOMAIN}
}
}
handle_path /amazonaws/* {
reverse_proxy * https://prod-registry-k8s-io-us-west-1.s3.dualstack.us-west-1.amazonaws.com {
header_up Host prod-registry-k8s-io-us-west-1.s3.dualstack.us-west-1.amazonaws.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_down Set-Cookie prod-registry-k8s-io-us-west-1.s3.dualstack.us-west-1.amazonaws.com k8s-io.{$DOMAIN}
}
}
@docker {
header_regexp User-Agent docker
}
handle @docker {
reverse_proxy * https://registry.k8s.io {
header_up Host registry.k8s.io
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie registry.k8s.io k8s-io.{$DOMAIN}
header_down Www-Authenticate "Bearer realm=\"https://k8s-io.{$DOMAIN}/v2/token\",service=\"registry.k8s.io\""
header_down Location "^https://[a-zA-Z0-9-]+.docker.pkg.dev" "https://k8s-pkg-dev.{$DOMAIN}"
header_down Location "^https://[a-zA-Z0-9-]+.s3.dualstack.[a-zA-Z0-9-]+.amazonaws.com" "https://k8s-io.{$DOMAIN}/amazonaws"
}
}
}
k8s-pkg-dev.{$DOMAIN}:{$PORT} {
reverse_proxy * https://us-west1-docker.pkg.dev {
header_up Host us-west1-docker.pkg.dev
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_down Set-Cookie us-west1-docker.pkg.dev k8s-pkg-dev.{$DOMAIN}
}
}
github.{$DOMAIN}:{$PORT} {
reverse_proxy * https://raw.githubusercontent.com {
header_up Host raw.githubusercontent.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie raw.githubusercontent.com github-file.{$DOMAIN}
}
@git {
header_regexp User-Agent git
}
handle @git {
reverse_proxy * https://github.com {
header_up Host github.com
header_down Set-Cookie github.com github.{$DOMAIN}
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Location "https://objects.githubusercontent.com" "https://github-file.{$DOMAIN}/githubusercontent-download"
}
}
}
github-file.{$DOMAIN}:{$PORT} {
handle_path /githubusercontent-download/* {
reverse_proxy * https://objects.githubusercontent.com {
header_up Host objects.githubusercontent.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
}
}
reverse_proxy * https://github.com {
header_up Host github.com
header_up X-Real-IP {http.request.remote.host}
header_up X-Forwarded-For {http.request.remote.host}
header_up X-Forwarded-Port {http.request.port}
header_up X-Forwarded-Proto {http.request.scheme}
header_down Set-Cookie github.com github-file.{$DOMAIN}
header_down Location "objects.githubusercontent.com" "github-file.{$DOMAIN}/githubusercontent-download"
}
}