Repository navigation
Expand file tree
/
Copy pathCaddyfile
More file actions
70 lines (60 loc) · 2.6 KB
/
Copy pathCaddyfile
File metadata and controls
70 lines (60 loc) · 2.6 KB
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
{
admin off
persist_config off
auto_https off
}
# Mirrors the language negotiation of the former SvelteKit server.
# A saved choice wins: deploio_language, or a legacy non-German paraglide_lang.
(language_redirect) {
@saved_{args[0]} {
method GET HEAD
header Accept text/html*
not path /en /en/* /fr /fr/* /it /it/*
expression `{http.request.cookie.deploio_language} == "{args[0]}" || (!({http.request.cookie.deploio_language} in ["de", "en", "fr", "it"]) && {http.request.cookie.paraglide_lang} == "{args[0]}")`
}
redir @saved_{args[0]} /{args[0]}{uri} 302
# Skip unsupported languages, then match when this is the first supported one.
@browser_{args[0]} {
method GET HEAD
header Accept text/html*
not path /en /en/* /fr /fr/* /it /it/*
header_regexp Accept-Language `(?i)^(?:\s*(?:\*|[a-z]{3,8}|[abcghj-z][a-z]|d[a-df-z]|e[a-mo-z]|f[a-qs-z]|i[a-su-z])(?:-[a-z0-9]{1,8})*(?:\s*;\s*q=[0-9.]+)?\s*,)*\s*{args[0]}(?:-[a-z0-9]{1,8})*\s*(?:[;,]|$)`
expression `!({http.request.cookie.deploio_language} in ["de", "en", "fr", "it"]) && !({http.request.cookie.paraglide_lang} in ["en", "fr", "it"])`
}
redir @browser_{args[0]} /{args[0]}{uri} 302
}
:{$PORT:8080} {
root * /srv
redir /claude_skill https://github.com/ninech/deploio-skills 301
redir /claude_skill/ https://github.com/ninech/deploio-skills 301
redir /slack https://join.slack.com/t/deploiocommunity/shared_invite/zt-20tb3k93m-O4NEUs0RjZYGQNQoih8zkA 302
redir /slack/ https://join.slack.com/t/deploiocommunity/shared_invite/zt-20tb3k93m-O4NEUs0RjZYGQNQoih8zkA 302
redir /terms https://docs.nine.ch/docs/legal-documents/general-terms-and-conditions/ 301
redir /terms/ https://docs.nine.ch/docs/legal-documents/general-terms-and-conditions/ 301
# German lives at the root. Unprefixed pages redirect to /en, /fr or /it
# when the visitor picked that language (cookie set by the language switcher)
# or, without a saved choice, when it is their first supported browser language.
@unprefixed_page {
method GET HEAD
header Accept text/html*
not path /en /en/* /fr /fr/* /it /it/*
}
header @unprefixed_page Vary "Accept-Language, Cookie"
import language_redirect en
import language_redirect fr
import language_redirect it
encode gzip zstd
try_files {path} {path}/index.html {path}.html
handle_errors {
@404 expression {err.status_code} == 404
handle @404 {
# Serve the not-found page in the language of the requested path.
@localized path_regexp lang ^/(en|fr|it)(?:/|$)
@german not path_regexp ^/(en|fr|it)(?:/|$)
rewrite @localized /{re.lang.1}/404/index.html
rewrite @german /404/index.html
file_server
}
}
file_server
}