for anyone else who stumbles upon this.
This is my example caddyfile that works
{
#debug
# Global options block. Entirely optional, https is on by default
# Optional email key for lets encrypt, uncomment the below to set the email i.e. email [email protected]
# email [email protected]
}
(static) {
@static {
file
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.woff2 *.json
}
header @static Cache-Control max-age=5184000
}
(security) {
header {
# enable HSTS
Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
# disable clients from sniffing the media type
X-Content-Type-Options nosniff
# keep referrer data off of HTTP connections
Referrer-Policy no-referrer-when-downgrade
}
}
(404) {
handle_errors {
@404 {
expression {http.error.status_code} == 404
}
handle @404 {
respond * "Not found" 404
}
}
}
yourdomain.com {
reverse_proxy web:4200
@ws {
header Connection *Upgrade*
header Upgrade websocket
}
handle /api/* {
# CORS settings
header Access-Control-Allow-Origin *
header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE'
header Access-Control-Allow-Headers 'Content-Type, Authorization'
# Proxy settings, strip /api prefix before proxying
reverse_proxy api:3000
}
reverse_proxy @ws ws:3002
reverse_proxy /widget widget:4500
}