Configure nixpacks to use Caddy

This commit is contained in:
2024-10-16 00:31:35 -05:00
parent a72e2123bf
commit 3b4dc2a7c2
3 changed files with 64 additions and 1 deletions

36
frontend/Caddyfile Normal file
View File

@@ -0,0 +1,36 @@
{
# 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 would cause issues if left enabled
log {
# runtime logs
format json # set runtime log format to json mode
}
servers {
# server options
trusted_proxies static private_ranges 100.0.0.0/8 # trust railway's proxy
}
}
# site block, listens on the $PORT environment variable, automatically assigned by railway
:{$PORT} {
respond /health 200
encode gzip
log {
# access logs
format json # set access log format to json mode
}
handle /api/* {
reverse_proxy {$BACKEND_URL} # reverse proxy to the backend
}
handle {
root * dist
file_server
# if path doesn't exist, redirect it to 'index.html' for client side routing
try_files {path} /index.html
}
}