← Holocron Logs

Three Layers Between a Browser and an S3 Bucket

Image uploads in Outline failed against a self-hosted Garage bucket. The failure had three separate causes stacked on top of each other: a CORS rule missing POST, an HTTP bucket behind an HTTPS app, and a signing region baked into a container at creation.

Why this matters beyond the homelab: A failed browser upload to object storage rarely has one cause. CORS, mixed content, and request signing are separate layers, and each fix exposes the next, on any S3-compatible service.


The Setup

Outline, the fleet’s documentation tool, stores uploaded images in an S3-compatible bucket. Instead of Cloudflare R2, the target was Garage v2.1.0, a self-hosted S3-compatible store, chosen for the hands-on experience. Outline uploads by having the browser talk to the bucket directly using a presigned request, which is what makes CORS matter at all. Pasting an image into a document returned “upload failed,” with nothing useful on Outline’s side.


Layer 1: CORS Methods

Garage has no bucket subcommand for CORS. The first attempt used its JSON API route, which accepted the command and silently changed nothing. The working path is the standard S3 call, and it needs the key to hold owner permission on the bucket temporarily:

docker exec garage /garage bucket allow --owner outline-uploads --key outline-key

export CORS='{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT","POST","HEAD"],"AllowedOrigins":["https://outline.tima.dev"],"ExposeHeaders":["ETag"]}]}'
aws --endpoint http://127.0.0.1:3900 s3api put-bucket-cors --bucket outline-uploads --cors-configuration "$CORS"
aws --endpoint http://127.0.0.1:3900 s3api get-bucket-cors --bucket outline-uploads

The first rule I wrote copied an example from Garage’s own docs for a different application, and allowed GET, PUT, and HEAD. Outline’s upload is a signed multipart POST, so the rule never covered it. The get-bucket-cors readback is the step that caught it: the instruction was to read the output before moving on and not continue until POST appeared in the list. After that, ownership is revoked and the shell is cleaned up:

docker exec garage /garage bucket deny --owner outline-uploads --key outline-key

The origin is scoped to the one Outline hostname instead of a wildcard.


Layer 2: Mixed Content

With CORS fixed, the next failure was in the browser console. Outline is served over HTTPS and the bucket URL was plain HTTP. Browsers block that combination before CORS is even evaluated, so it had been hiding behind the first problem. The fix was the same pattern every other service on the fleet uses: put Garage behind Nginx Proxy Manager at garage.tima.dev with a real Let’s Encrypt certificate.


Layer 3: A Stale Signing Region

With CORS and HTTPS both working, uploads still returned a 400, and this time the response body named the problem:

AuthorizationHeaderMalformed ... unexpected scope: westus2

Garage signs requests with the region garage. The Outline container thought its region was westus2, a leftover from an earlier Azure configuration. What made it confusing is that the secrets manager showed garage correctly. But docker exec outline env on the running container still said westus2. The value had been baked in when the container was created, and a plain restart does not re-read it.

The fix was a full docker compose down followed by a fresh run of the deploy script, which pulls current values from Infisical. The same lesson applies to the CLI side: use AWS_DEFAULT_REGION=garage and path-style addressing (s3.addressing_style=path) when talking to Garage, since it doesn’t use virtual-hosted bucket names.


Verification

The upload succeeded in the browser with no CORS error and no mixed-content warning. But “the UI says success” was not the standard. On the storage side:

docker exec garage /garage bucket info outline-uploads

showed one object and 222.9 KiB. Real data was physically in the bucket.


The Lesson

Three independent mechanisms, a policy, a transport, and a signature, all produced the same generic browser error. The reliable method was to change one thing, read the actual evidence from the Network tab and the container, and only then move on. The secrets manager showing the right value was not proof the process had it. Check the running thing, not the source of truth for the running thing.


Related: I Said Act Three Had No New Services. Then I Deployed Four. | One Secrets Manager, Three Injection Patterns | Chrome Private Network Access vs Your Homelab Portfolio | NPM and UniFi Firewall Rule Ordering: The Silent Traffic Drop

← Back to Holocron Logs