From 0e034e0da3efc45cd928a8e9e24a224549a5b85b Mon Sep 17 00:00:00 2001 From: Kenneth Obsequio Date: Tue, 22 Sep 2026 13:06:07 +0800 Subject: [PATCH] refactor: Caddy for s3 Signed-off-by: Kenneth Obsequio --- Caddyfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Caddyfile b/Caddyfile index 7724ab9..00bc45b 100644 --- a/Caddyfile +++ b/Caddyfile @@ -55,6 +55,23 @@ } {$CDN_DOMAIN:cdn.yourdomain.com} { + # Browser-direct presigned PUT uploads need a storage CORS preflight. + # Garage's default bucket policy only advertises GET, so handle the + # browser preflight at the public edge and expose multipart ETags. + @storage_preflight method OPTIONS + header @storage_preflight { + Access-Control-Allow-Origin "{http.request.header.Origin}" + Access-Control-Allow-Methods "GET, HEAD, PUT, POST, DELETE, OPTIONS" + Access-Control-Allow-Headers "*" + Access-Control-Max-Age "86400" + } + respond @storage_preflight 204 + + header { + Access-Control-Allow-Origin "*" + Access-Control-Expose-Headers "ETag, Content-Length, Content-Range, Accept-Ranges, Content-Disposition" + } + reverse_proxy localhost:3900 { header_up X-Real-IP {http.request.header.X-Real-IP} }