Fix presigned URLs with an internal Docker hostname: sign for the address the browser can reach

On this page
Your app runs in Docker Compose next to an S3-compatible server such as MinIO, RustFS, Garage or SeaweedFS. It signs a presigned URL for the browser, and the URL starts with http://minio:9000, the Compose service name. The browser can’t use that address, and if you edit the host by hand, the server answers SignatureDoesNotMatch. An open October 2026 issue asks for exactly this: presigned URLs that “use a host the browser can reach (localhost, not the compose service name)” (candiedoperation/TechOps #108).
Below are the cause, a curl check that tells the failures apart, and the fix in the AWS SDK for JavaScript v3 and boto3, then the path-style and region settings that break it next. Once the host is right, the browser still needs a CORS rule on that endpoint.
Nothing below has been run for this post; it is built from the documentation linked at each step, so try it on a throwaway stack first.
The URL carries the host your SDK signed for
A presigned URL is valid only for the host it was signed for, because Signature Version 4 signs the Host header. Your SDK builds the URL locally from the endpoint you gave it, so a client set to http://minio:9000 signs for minio:9000. Sign with a second client whose endpoint is the address the browser uses.
The host and port are part of the signature
AWS’s signing rules say you must include “the host header (HTTP/1.1) or the :authority header (HTTP/2)” in the signature (AWS, Create a signed AWS API request). The Host header holds the host and the port (RFC 9110, section 7.2), so minio:9000, localhost:9000 and files.example.com (example) are three different signed values for one server.
The server checks the Host it actually received. MinIO’s verifier reads a signed host header from the incoming request (extractedSignedHeaders.Set(header, r.Host) in signature-v4-utils.go) and returns ErrSignatureDoesNotMatch when its recomputed signature differs (signature-v4.go). SeaweedFS’s wiki states the same rule (SeaweedFS, S3 Nginx Proxy), and RustFS’s docs say the hostname, scheme, port, region and object path “must match the values used to sign the URL” (RustFS, S3 protocol).
Inside Compose, the app and the browser use different addresses
In Compose, containers reach each other by service name, service-to-service traffic uses the container port, and “the host port is only used when accessing the service from outside the network” (Docker, Networking in Compose). The browser sits outside that network, so it reaches only the published port, such as localhost:9000, or a public domain in front of it.
Presigning makes no network call, which is why the fix works. AWS says “Creating a presigned URL happens locally” (AWS, presigned URLs), and Cloudflare says R2 presigned URLs are generated “with no communication with R2” (Cloudflare R2, Presigned URLs). So the app container can sign for the browser’s address without connecting to it.
Sign the URL for the address the browser can reach: localhost:9000 works from outside Compose, rustfs:9000 does not. Drawn from Docker’s Compose networking docs, not from a live run.
Check which failure you have with curl
Start with the URL itself: its host and port are the signed host, and the X-Amz-SignedHeaders query parameter lists the signed headers (Cloudflare R2, Presigned URLs). To confirm, run curl from your machine, not from a container. <PRESIGNED_URL> is the URL your app printed, and the single quotes keep its & characters intact:
curl -v '<PRESIGNED_URL>'These outcomes are predicted from the signing rules; no test run has captured them yet:
- curl can’t resolve the host or can’t connect. The URL was signed for an internal name. Go to the fix below.
- HTTP 403 with SignatureDoesNotMatch. The request differs from what was signed; AWS says the method, headers and query string must “match exactly between URL generation and usage” (AWS, presigned URLs). If you edited the host, that is the cause. If not, compare the signed headers with what the browser sent.
- AuthorizationHeaderMalformed on Garage. Garage rejects calls signed for a region other than its configured one with this error (Garage, configuration). Go to the region section.
Two fixes that don’t work
Replacing the host after signing
Editing minio:9000 to localhost:9000 in a signed URL changes the Host the server receives, so its recomputed signature no longer matches.
A server setting such as MINIO_SERVER_URL
You may see MINIO_SERVER_URL suggested as the fix. MinIO’s docs mark it “Deprecated since version RELEASE.2024-05-10T01-41-38Z” and describe it in terms of Console logins, with nothing about presigned URLs (MinIO AIStor, deprecated settings). Your SDK computes the URL inside your app, so no server environment variable can change a URL your app has already signed. Where a setup with it works, check whether the app’s client already points at the public domain.
The fix: one client for server calls, one for presigning
Keep two clients with the same keys, region and path-style setting. The internal client uses http://rustfs:9000 for every server-side call. The presign client uses the browser’s address and only signs: http://localhost:9000 in development, or a public domain such as https://files.example.com (example) in production.
The Compose file
This example runs RustFS, which uses the image rustfs/rustfs, serves the S3 API on port 9000 and the Console on 9001, and reads its root keys from RUSTFS_ACCESS_KEY and RUSTFS_SECRET_KEY (RustFS, Docker install). Values in angle brackets are placeholders. Set your own root keys before the stack is reachable from a network: RustFS’s docs say port 9000 also carries administrative and internode traffic, so do not expose it without network and IAM controls (RustFS, S3 protocol).
# compose.yaml (example, untested)
services:
rustfs:
image: rustfs/rustfs:latest
ports:
- "9000:9000" # S3 API, published for the browser
- "9001:9001" # Console
environment:
RUSTFS_ACCESS_KEY: "<ROOT_ACCESS_KEY>"
RUSTFS_SECRET_KEY: "<ROOT_SECRET_KEY>"
RUSTFS_ADDRESS: ":9000"
RUSTFS_CONSOLE_ADDRESS: ":9001"
RUSTFS_CONSOLE_ENABLE: "true"
volumes:
- rustfs-data:/data
app:
build: . # your app
depends_on:
- rustfs
environment:
S3_INTERNAL_ENDPOINT: "http://rustfs:9000" # service name, container port
S3_PUBLIC_ENDPOINT: "http://localhost:9000" # the address the browser uses
S3_REGION: "us-east-1"
S3_BUCKET: "<BUCKET>"
S3_ACCESS_KEY: "<ACCESS_KEY>"
S3_SECRET_KEY: "<SECRET_KEY>"
volumes:
rustfs-data:If you publish 9100:9000 instead, the public endpoint becomes http://localhost:9100 and the internal one stays http://rustfs:9000, because containers talk on the container port (Docker, Networking in Compose). For other options, see RustFS’s Docker guide.
On Garage, use the port and region from its quick start: S3_INTERNAL_ENDPOINT=http://garage:3900, S3_PUBLIC_ENDPOINT=http://localhost:3900 and S3_REGION=garage, with garage as the example service name (Garage, quick start).
On MinIO, the fix is the same, with http://minio:9000 as the internal endpoint. The minio/minio repository was archived on April 25, 2026, and its README says the community edition “is now distributed as source code only”, so a Compose file that pulls a ready-made image may fail. We did not check the image registries; use the MinIO image you already run.
Console steps: bucket, test object and access key (RustFS)
The signer needs a bucket, an object and a key. These RustFS steps follow its docs for creating a bucket, uploading an object and access keys:
- Open
http://localhost:9001and sign in to the RustFS Console. - On the Buckets page, in the top right corner, select Create Bucket. Enter a bucket name and select Create.
- Select the bucket. In the top right corner, select Upload File/Folder, select a file and click Start Upload.
- In the left navigation, select Access Keys. In the upper right corner, click Add Access Key.
- Enter an Expiration, Name and Description for the key, then select Submit. On the page that appears, select Copy or Export to save the key.
On Garage, the quick start’s environment variables create the bucket and key. Put the new key into S3_ACCESS_KEY and S3_SECRET_KEY, and scope that key to one bucket.
AWS SDK for JavaScript v3
The module checks the object through the internal client, then signs a GET URL with the presign client. getSignedUrl from @aws-sdk/s3-request-presigner takes the client, the command and expiresIn in seconds, which defaults to 900 (@aws-sdk/s3-request-presigner README). Untested: it has not run against a demo server.
// presign.mjs: sign a GET URL the browser can use (example, untested)
// npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner
import { S3Client, HeadObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
const base = {
region: process.env.S3_REGION, // us-east-1 here; garage on Garage
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY, // <ACCESS_KEY>
secretAccessKey: process.env.S3_SECRET_KEY, // <SECRET_KEY>
},
forcePathStyle: true, // bucket in the path, not the hostname
};
// Server-side calls: Compose service name and container port.
const internal = new S3Client({ ...base, endpoint: process.env.S3_INTERNAL_ENDPOINT });
// Signing only: the address the browser uses.
const presigner = new S3Client({ ...base, endpoint: process.env.S3_PUBLIC_ENDPOINT });
const Bucket = process.env.S3_BUCKET; // <BUCKET>
const Key = "<KEY>"; // an object you uploaded, for example test.txt
try {
await internal.send(new HeadObjectCommand({ Bucket, Key }));
const url = await getSignedUrl(presigner, new GetObjectCommand({ Bucket, Key }), {
expiresIn: 900, // seconds
});
console.log(url);
} catch (err) {
console.error(`${err.name}: ${err.message}`);
process.exitCode = 1;
}The option name forcePathStyle comes from LocalStack’s SDK guide (LocalStack, AWS SDK for JavaScript); the official reference did not load for us, so check it against the S3ClientConfig type in your installed @aws-sdk/client-s3. For uploads, sign a PutObjectCommand with the same presign client; if you set ContentType, the browser must send a matching Content-Type header (Cloudflare R2, aws-sdk-js-v3).
Python (boto3)
The script sets signature_version="s3v4" because the Host rule above is the Signature Version 4 rule, and AWS’s boto3 guide recommends s3v4 for presigned URLs (Boto3, presigned URLs). generate_presigned_url expires after 3600 seconds by default (Boto3, generate_presigned_url), so the script sets 900. Untested, like the JavaScript module.
# presign.py: sign a GET URL the browser can use (example, untested)
# pip install boto3
import os
import sys
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError, EndpointConnectionError
cfg = Config(signature_version="s3v4", s3={"addressing_style": "path"})
def make(endpoint):
return boto3.client(
"s3",
endpoint_url=endpoint,
region_name=os.environ["S3_REGION"],
aws_access_key_id=os.environ["S3_ACCESS_KEY"], # <ACCESS_KEY>
aws_secret_access_key=os.environ["S3_SECRET_KEY"], # <SECRET_KEY>
config=cfg,
)
internal = make(os.environ["S3_INTERNAL_ENDPOINT"]) # server-side calls
presigner = make(os.environ["S3_PUBLIC_ENDPOINT"]) # signing only
bucket = os.environ["S3_BUCKET"] # <BUCKET>
key = "<KEY>" # an object you uploaded
try:
internal.head_object(Bucket=bucket, Key=key)
url = presigner.generate_presigned_url(
"get_object",
Params={"Bucket": bucket, "Key": key},
ExpiresIn=900, # seconds; the default is 3600
)
print(url)
except (ClientError, EndpointConnectionError) as e:
print(f"{type(e).__name__}: {e}", file=sys.stderr)
sys.exit(1)Keep the expiry short in both: AWS calls presigned URLs “bearer tokens that grant access to those who possess them” (AWS, presigned URLs).
Path-style and region: the two settings that break it next
Use path-style addressing
Virtual-hosted style puts the bucket name into the hostname (AWS, virtual hosting), giving hosts such as <BUCKET>.localhost:9000 or <BUCKET>.rustfs:9000; Garage’s docs say this style needs a wildcard DNS entry (Garage, configuration). LocalStack’s guide says the JavaScript v3 client uses virtual-host addressing by default, and boto3’s default, auto, “Attempts to use virtual, but falls back to path if necessary” (Boto3, configuration). So both programs set path-style explicitly. AWS’s boto3 guide recommends virtual-hosted style for presigning, advice meant for Amazon S3 itself.
Sign with the region the server expects
The region sits in the signature’s credential scope, which “restricts the resulting signature to the specified Region and service” (AWS, Create a signed AWS API request). A wrong region can fail even when the host is right, and no single value fits every server:
| Server | API port in the cited source | Path-style | Region to sign with |
|---|---|---|---|
| RustFS | 9000 (Docker install) | The default (S3 protocol) | us-east-1 by default (RUSTFS_REGION); whether the server enforces it is not confirmed |
| Garage | 3900 (quick start) | Always on (configuration) | The configured s3_region, garage in the quick start; other regions get AuthorizationHeaderMalformed |
| MinIO | 9000 (aws-sdk-js-v3 #2726) | Only path-style without MINIO_DOMAIN, per the AIStor docs (core settings); community build not confirmed |
Any region, when the server has none configured (signature-v4-parser.go) |
Behind a reverse proxy or a public domain
In production, sign with the public HTTPS URL the browser uses, which RustFS calls “the externally reachable endpoint” (RustFS, S3 protocol). The proxy must pass on the Host the browser sent, since MinIO verifies against the Host it receives. Garage needs a proxy for HTTPS anyway: its S3 endpoint “does not support TLS” (Garage, configuration). SeaweedFS can pin the host it verifies with -s3.externalUrl, or rebuild it from X-Forwarded-Host and X-Forwarded-Port (SeaweedFS, S3 Nginx Proxy). We have no tested proxy config to show.
Check it end to end
Run the signer in the app container, whose image must contain the script and its packages, then request the printed URL from your machine:
docker compose run --rm app node presign.mjs # or: python presign.py
curl -v '<PRESIGNED_URL>'If the fix works, curl gets HTTP 200 and the URL opens in the browser. If curl works but a browser upload from your page is blocked, look at CORS: on MinIO, set MinIO’s server-wide origin list (MINIO_API_CORS_ALLOW_ORIGIN); AIStor also accepts per-bucket rules that override it. On other servers, add a CORS rule on the bucket that allows your page’s origin.
Any browser client follows the same rule: if you run a self-hosted Opndrive next to a local server, enter the endpoint the browser can reach, such as http://localhost:9000, because the guide to connecting storage says the browser talks to S3 directly.
Try Opndrive
Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.
See it on GitHub or read the docs.



