-
Notifications
You must be signed in to change notification settings - Fork 28
/
Caddyfile
49 lines (42 loc) · 1.58 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
{$DOMAIN:http://localhost} {
# Redirect various old URL that have been now replaced:
redir /toolkit / 308
redir /toolkit/ / 308
redir /mock / 308
redir /mock/ / 308
redir /view / 308
redir /view/ / 308
redir /docs/guides/subscription-faq/ /docs/faq/payments/ 308
redir /docs/reference/mock-page/ /docs/reference/modify-page/ 308
redir /docs/reference/amiusing.httptoolkit.tech/ /docs/reference/amiusing/ 308
# Redirect old download paths to new ones
@view-thankyou-subpath path_regexp subpath ^/view/thank-you/(.+)
redir @view-thankyou-subpath /download/{re.subpath.1} 308
@view-subpath path_regexp subpath ^/view/(.+)
redir @view-subpath /{re.subpath.1} 308
@mock-subpath path_regexp subpath ^/mock/(.+)
redir @mock-subpath /{re.subpath.1} 308
# Enforce trailing slashes
@no_slash {
not path_regexp ^/.+/$
not path /
not file {
try_files {path}
}
}
redir @no_slash {path}/ 301
root * /site
try_files {path}.html {path} {path}/index.html
file_server
encode zstd gzip
# Cache GET responses for 10 minutes, validate async during next minute, or continue serving
# old data as-is for up to 1 hour if this server stops responding/returns errors.
@get method GET
header @get Cache-Control "public, max-age=600, stale-while-revalidate=60, stale-if-error=3600"
header X-Clacks-Overhead "GNU Terry Pratchett" # https://xclacksoverhead.org
handle_errors {
@404 `{err.status_code} == 404`
rewrite @404 /404.html
file_server
}
}