-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCaddyfile
299 lines (242 loc) · 7.22 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#
# Caddy configuration for Trading Strategy website/backend APIs.
#
# Contains both production and staging environments.
#
#
{
# Disable the Caddy admin API
# This is personal preference, you can remove this if desired
admin off
email [email protected]
log {
output file /var/log/caddy/access.log
format json
}
# Caddy must be told custom rate_limit module its order
order rate_limit before basicauth
}
#
# Shared snippet for frontend deployments
#
# Accepts single argument:
# - port where SvelteKit node.js server is running
#
# /api requests are proxied to backend service on port 3456
# /docs requests are served from /docs static files
#
(frontend) {
vars frontend_port {args[0]}
# Backend API request
handle /api* {
# Rate limit /API end point to XX requets a minute
rate_limit {
window 1m
events 150
}
# This is the upstream Waitress server
reverse_proxy 127.0.0.1:3456 {
# Backend API must respond to an individual API call under 20s seconds
transport http {
# Increase 20s -> 90s for /top endpoint
response_header_timeout 90s
}
}
}
# Special URL endpoint for Google and other bots
# that are robots.txt blocked from API
handle_path /sitemap/* {
# Same as /api, just a path rewrite using Caddy handle_path
# https://webinstall.dev/caddy/
rewrite * /api{path}
reverse_proxy 127.0.0.1:3456
}
# Serve docs as files rsync'ed to the server
# See trading-strategy/.github/workflows/rsync-docs.yml for more details
# https://caddy.community/t/caddy-file-server-browse-not-working-when-root-a-specific-directory/15342/3
redir /docs /docs/
handle_path /docs* {
# See docker-compose
# mapped to /home/docs/html
root * /docs
file_server
}
# SvelteKit production server from frontend repository
handle {
reverse_proxy 127.0.0.1:{vars.frontend_port} {
header_up X-Forwarded-Host {host}
# Frontend must render the page under 20 seconds
transport http {
response_header_timeout 20s
}
}
}
# Set the default 404 page
# https://caddyserver.com/docs/caddyfile/directives/handle_errors
handle_errors {
respond "{http.error.status_code} {http.error.status_text}"
}
# Create a log file.
# This is mapped to local FS thru docker-compose, so you can read it like
# tail -f logs/access.log | jq
# but it is also consumed by logstash log forwarder
log {
format json
output file /var/log/caddy/access.log
#output stdout
# Caddy cannot have two log outputs at the same time
}
}
# Main frontend site (port 3000)
http://tradingstrategy.ai {
import frontend 3000
}
# Strategy microsite frontend instance (port 3001)
http://memecoin-index.tradingstrategy.ai {
import frontend 3001
}
# New backend testing server
http://por-que.tradingstrategy.ai {
# Backend API request
handle /api* {
# This is the upstream Gunicorn server
reverse_proxy 127.0.0.1:3457 {
# Backend API must respond to an individual API call under 20 seconds
transport http {
response_header_timeout 20s
}
}
}
}
#
# Staging server.
#
# Pushed from a specific branch.
#
# Frontend - SvelteKit node.js adapter: 4000
#
# To run the SvelteKit frontend in tmux on the server see frontend/docs/staging.md
#
# Protected by HTTP Basic Auth, so that the website is not picked up by robots.
# The password is not super secret.
#
http://pinky.tradingstrategy.ai {
# Staging Backend API requests
# Handled by Matilda (see below)
handle /api* {
reverse_proxy 127.0.0.1:4567 {
header_up X-Real-IP {remote_host}
}
}
# Docs not available staging
#handle /docs* {
# reverse_proxy https://boring-poitras-17190b.netlify.app {
# header_up Host boring-poitras-17190b.netlify.app
# }
#}
# SvelteKit production server from frontend repository
handle {
# Protect with password to prevent the server ending up in the Google index.
# The password is angrybird, generated with cadddy hash-password.
# This is mostly protecting against indexing.
# https://caddyserver.com/docs/caddyfile/directives/basicauth
basicauth {
pinky JDJhJDE0JFFpeTFyWHdKSkhwQzBsQkk3TGhkNnVEQW1WcnkzclhzTlJlaWVQMnpLVkxyNVh5Q1pIanIu
}
reverse_proxy 127.0.0.1:4000 {
header_up X-Real-IP {remote_host}
}
}
}
# Server for oracle data
http://candlelightdinner.tradingstrategy.ai {
reverse_proxy 127.0.0.1:6543 {
header_up X-Real-IP {remote_host}
}
}
# Server for web backend
# https://docs.pylonsproject.org/projects/waitress/en/latest/reverse-proxy.html
http://matilda.tradingstrategy.ai {
reverse_proxy 127.0.0.1:3456 {
header_up X-Real-IP {remote_host}
# header_upstream X-Forwarded-Proto https
}
}
# Integration test backend server
http://steve.tradingstrategy.ai {
reverse_proxy 127.0.0.1:3457 {
header_up X-Real-IP {remote_host}
}
}
#
# Development trade-executor instances
#
#
# pancake-eth-usd-sma trade executor
#
# See https://tradingstrategy.ai/docs for details.
# Internal 19003 port is set in docker-compose.yml
#
http://pancake-eth-usd-sma.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19003
}
http://trader-joe-avax-usd-ema.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19004
}
http://quickswap-matic-usd-ema-final.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19005
}
http://enzyme-polygon-eth-usdc.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19006
}
http://enzyme-polygon-multipair.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19007
}
http://enzyme-polygon-matic-usdc.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19008
}
http://enzyme-polygon-eth-usdc-sls.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19009
}
http://polygon-multipair-momentum.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19010
}
http://polygon-eth-spot-short.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19011
}
http://test-strategy-1.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19012
}
http://arbitrum-btc-breakout.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19014
}
# arbitrum-btc-eth-stoch-rsi strategy - Alex
http://arbitrum-btc-eth-stoch-rsi.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19015
}
# enzyme-polygon-stoch-rsi strategy - Alex
http://enzyme-polygon-stoch-rsi.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19016
}
# enzyme-ethereum-stoch-rsi strategy - Alex
http://enzyme-ethereum-stoch-rsi.tradingstrategy.ai {
reverse_proxy 127.0.0.1:19017
}
# docs.capitalgram.com migration in Google Search Console
http://docs.capitalgram.com {
root * /docs
file_server
# Set the default 404 page
# https://caddyserver.com/docs/caddyfile/directives/handle_errors
handle_errors {
respond "{http.error.status_code} {http.error.status_text}"
}
}
#
# Metrics
#
# Expose Caddy OpenMetrics end-point at localhost port 6000
#
http://127.0.0.1:6000 {
metrics /metrics
}