-
Notifications
You must be signed in to change notification settings - Fork 21
/
Caddyfile
86 lines (75 loc) · 2.35 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
# global options
{
admin off # theres no need for the admin api in railway's environment
persist_config off # storage isn't persistent anyway
auto_https off # railway handles https for us, this could in some cases cause issues if left enabled
# runtime logs
log {
format json # set runtime log format to json mode
}
# server options
servers {
trusted_proxies static private_ranges # trust railway's proxy
}
}
(lb_settings) {
lb_policy round_robin
lb_retries 100
lb_try_duration 10s
lb_try_interval 250ms
}
(passive_health_checks) {
fail_duration 60s
max_fails 300
unhealthy_latency 5s
unhealthy_request_count 200
}
# site block, listens on the $PORT environment variable, automatically assigned by railway
:{$PORT} {
# access logs
log {
format json # set access log format to json mode
}
# proxy all requests for /* to the frontend, configure these variables in the service settings
reverse_proxy {
# for private networking replicas are exposed as multiple dns results, use those dns results as the upstreams
dynamic a {
name {$FRONTEND_DOMAIN}
port {$FRONTEND_PORT}
refresh 1s
dial_timeout 30s
versions ipv4 ipv6
}
# configure load balancing settings
import lb_settings
# configure passive health checks
import passive_health_checks
# sets the Host header to the header to the dynamic name and port options
header_up Host {upstream_hostport}
}
# the handle_path directive WILL strip /api/ from the path before proxying
# use `handle` instead of `handle_path` if you dont want to strip the /api/ path
# this is needed if your backend's api routes don't start with /api/
# change paths as needed
handle_path {$BACKEND_PATH:/api}/* {
# the /api/ prefix WILL be stripped from the uri sent to the proxy host
#
# proxy all requests for /api/* to the backend, configure this variable in the service settings
reverse_proxy {
# for private networking replicas are exposed as multiple dns results, use those dns results as the upstreams
dynamic a {
name {$BACKEND_DOMAIN}
port {$BACKEND_PORT}
refresh 1s
dial_timeout 30s
versions ipv4 ipv6
}
# configure load balancing settings
import lb_settings
# configure passive health checks
import passive_health_checks
# sets the Host header to the header to the dynamic name and port options
header_up Host {upstream_hostport}
}
}
}