-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaddyfile.prod
More file actions
80 lines (67 loc) · 1.82 KB
/
Caddyfile.prod
File metadata and controls
80 lines (67 loc) · 1.82 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
71
72
73
74
75
76
77
#Disable bot crawlings
{$WIKIADVISER_FRONTEND_ENDPOINT}/robots.txt {
respond "User-agent: *
Disallow: /
Noindex: /
Nofollow: /"
}
# Wikiadviser
{$WIKIADVISER_FRONTEND_ENDPOINT} {
log {
output file /var/log/caddy/access-app-prod.log {
roll_size 10MiB
roll_keep 10
roll_keep_for 24h
}
}
#### Mediawiki Prod ####
handle /wiki/* {
# Search articles in Wikipedia
@search_articles {
query action=query
query generator=prefixsearch
path_regexp ^/wiki/([a-z]{2})/api.php
}
handle @search_articles {
rewrite * /w/api.php?lang={re.1}&{query}
reverse_proxy wiki.adminforge.de:443 {
header_up Host wiki.adminforge.de
transport http {
tls
}
}
}
@needsAuth not header X-Api-Key {$X_API_KEY}
forward_auth @needsAuth {$SUPABASE_PROJECT_URL} {
header_up Host {upstream_hostport}
header_up X-Real-IP {remote_host}
uri /functions/v1/restrict-mediawiki-access
copy_headers X-User X-Client-IP X-Forwarded-Uri
}
header {
-X-Frame-Options
+Content-Security-Policy "frame-ancestors https://*.wikiadviser.io";
}
rewrite /robots.txt ./robots.txt # Disable search engine indexing
# Redirect simple article links to Wikipedia
# simple e.g. /wiki/en/index.php/Main_page
reverse_proxy wiki:8082 {
handle_response {
@find_lang_title path_regexp ^/wiki/([a-z]{2})/index.php/([^/?:]+)$
# Redirect simple articles
handle @find_lang_title {
redir https://{re.1}.wikipedia.org/wiki/{re.2} permanent
}
# Else, Continue
copy_response
}
}
}
#### WikiAdviser ####
handle {
root * /usr/share/caddy/html
encode gzip
try_files {path} /index.html
file_server
}
}