-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCaddyfile
More file actions
84 lines (68 loc) · 2.44 KB
/
Caddyfile
File metadata and controls
84 lines (68 loc) · 2.44 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
78
79
80
81
82
83
84
# this configuration file will set up caddy to serve the public and staff sites,
# with automatic https
# make sure the base html files aren't cached by visitor's browsers
(file-server) {
encode zstd gzip
@html {
path */
}
header @html {
Cache-Control "max-age=0,no-store"
}
}
# log requests to a file
(monitor) {
log {
output file /var/log/caddy/caddyhttp.json
format json
}
}
# for optimization, caddy will attempt to serve any static files that
# are requested directly; requests that don't match static files will be
# reverse proxied to the actual server. @notStatic is a matcher that will find
# requests that don't match static files.
# the syntax {path}.html makes it look for e.g. contact.html even when the
# url is just khe.io/contact
(matchNotStatic) {
@notStatic {
not {
file {
# the last of these is used to try /index.html when the path is just /
# these is probably a better way to do this
try_files {path} {path}.html {path}index.html
}
}
}
}
# add "dev." at the beginning of the next line to set up that subdomain
khe.io {
import monitor
import file-server
import matchNotStatic
# assuming the repository is cloned to this location:
root * /var/www/khe-revengeance/public-frontend/dist
# outside the matcher we still have to rewrite the actual request
try_files {path} {path}.html {path}index.html
reverse_proxy @notStatic localhost:3000 {
# add headers to tell the api server where this request came from
header_up Host {host}
header_up X-Real-IP {remote}
}
file_server
}
# change to staff.dev.khe.io to set up that subdomain
staff.khe.io {
import monitor
import file-server
import matchNotStatic
# assuming the repository is cloned to this location:
root * /var/www/khe-revengeance/staff-frontend/dist
# outside the matcher we still have to rewrite the actual request
try_files {path} {path}.html {path}index.html
reverse_proxy @notStatic localhost:3000 {
# add headers to tell the api server where this request came from
header_up Host {host}
header_up X-Real-IP {remote}
}
file_server
}