forked from sandstorm/caddy-nats-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaddyfile
27 lines (22 loc) · 746 Bytes
/
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
{
nats {
url 127.0.0.1:4222
clientName "My Caddy Server"
# listens to "datausa.[drilldowns].[measures]" -> calls internal URL
# nats req "datausa.Nation.Population" ""
subscribe datausa.> GET http://127.0.0.1:8888/datausa/{nats.request.subject.asUriPath.1}/{nats.request.subject.asUriPath.2}
}
}
http://127.0.0.1:8888 {
# internal URL: "/datausa/[drilldowns]/[measures]"
handle /datausa/* {
# Reference for placeholders: https://caddyserver.com/docs/json/apps/http/#docs
rewrite * /api/data?drilldowns={http.request.uri.path.1}&measures={http.request.uri.path.2}
reverse_proxy https://datausa.io {
header_up Host {upstream_hostport}
}
}
route /weather/* {
nats_request cli.weather.{http.request.uri.path.1}
}
}