Caddy Reverse Proxy for Self-Hosted S3: Host Header, HTTPS and Uploads

On this page
On MinIO, Garage and RustFS, a Caddy reverse proxy for S3 breaks when Caddy changes the Host header your client signed.
Quick start: Serve the S3 API on its own hostname with
reverse_proxyand leaveHostalone. If the upstream, the server Caddy forwards to, ishttps://, Caddy 2.11 rewritesHost, so addheader_up Host {hostport}.
s3.example.com {
reverse_proxy https://minio.internal:9000 {
header_up Host {hostport}
}
}
In this post:
- Why an S3 server rejects a request when Caddy changes Host
- Which Caddy versions rewrite Host for HTTPS upstreams
- Reproduce it with one presigned URL and two upstreams
- The fix: header_up Host {hostport}, not {host}
- Large uploads through a Caddy reverse proxy for S3
- Virtual-hosted buckets need a wildcard certificate
- Put the MinIO or RustFS console on its own hostname
How we tested: We ran the commands in this post on MinIO RELEASE.2025-07-23T15-54-02Z, SeaweedFS 4.52, Garage 2.6.0 and RustFS 1.0.7 on 3 Dec 2026. Each server got a fresh test bucket (
my-bucketin the commands) holding one small object, hello.txt, then a 64 MiB upload, big.bin, deleted after the run. The output under a command is MinIO’s; where a server printed something else, the note under it says so.What we read rather than ran: Which Caddy release first rewrote Host for HTTPS upstreams, and each server’s domain and console settings, from release notes, docs and source.
Why an S3 server rejects a request when Caddy changes Host
The client signs the Host header. The server rebuilds the signature from the Host it receives, so on MinIO, Garage and RustFS any change in between turns a valid request into a 403. Signature Version 4 (SigV4), the S3 API’s signing scheme, requires Host in every HTTP/1.1 signature[1]. A presigned URL, one whose query string carries the signature and expiry, lists host in X-Amz-SignedHeaders[2]. A mismatch returns HTTP 403 SignatureDoesNotMatch[3]. The path is signed too, so the RustFS Caddy guide says to serve the S3 API from the root path, never under /s3/[4].
Caddy’s default keeps both intact. The reverse_proxy directive passes incoming headers, Host included, to the backend unchanged. It adds X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, and sets Accept-Encoding: gzip when the client sent none.[5] That is why reverse_proxy http://127.0.0.1:9000 works with no extra lines. An https:// upstream is the exception. So is a header name with an underscore or a dot, which Caddy drops[6]. If your client signs x-amz-meta-* headers, keep hyphens in their names or list them in the experimental expected_underscore_headers and expected_dot_headers server options.[6]

A server that checks signatures answers 403 when Caddy 2.11 swaps the signed Host for the upstream’s address. Restoring Host fixes it.
Which Caddy versions rewrite Host for HTTPS upstreams
Caddy 2.11.1 and later rewrite Host for an https:// upstream; http:// upstreams are unchanged. The v2.11.1 release notes (23 February 2026) say the proxy “now automatically rewrites the Host header to the address of the upstream when the upstream is HTTPS”. Pull request #7454 sets it to {upstream_hostport}.[7]
The reverse_proxy docs say “Since Caddy v2.11.0”[5] because v2.11.0 never shipped. The v2.11.1 release notes explain there are no code changes from v2.11.0 other than a CI job, making v2.11.1 the first 2.11 release. One OpenCloud user whose setup broke on 2.11.1 got the old behavior back on v2.11.0-beta.2.[8] Treat every 2.11 release as affected, and pin the Caddy version you deploy.
Matt Holt replied in that thread: “The previous default was insecure in some common configurations.”[8] Check your version, and validate the Caddyfile after every edit:
caddy version
caddy validate --config Caddyfile --adapter caddyfilev2.11.9 h1:bhZtcRKQOq0fuLvEgCdPYvUxXyGn9kzjG4lh2332DTE=
Valid configuration
Tested on MinIO.
Reproduce it with one presigned URL and two upstreams
Send one presigned GET through a site with an http:// upstream and one with an https:// upstream. A 200 on the first and a 4xx on the second means the Host rewrite is the cause. This Caddyfile runs on one machine. Its first site stands in for an S3 server with its own certificate; point each http://127.0.0.1:9000 at your S3 API port.
These commands assume Linux (the Caddy CA path and GNU head -c 64M), the aws CLI, curl, python3 with boto3, credentials and a region for your server, and a bucket my-bucket holding hello.txt.
tls internal issues certificates from Caddy’s local certificate authority (CA),[9] and tls_trust_pool makes the proxy trust that CA upstream, so verification stays on. The global options skip the port 80 redirect and the system trust store.
{
skip_install_trust
auto_https disable_redirects
}
# Stand-in for an S3 server that serves its own certificate
localhost:9443 {
tls internal
reverse_proxy http://127.0.0.1:9000
}
# Plain HTTP upstream
localhost:8443 {
tls internal
reverse_proxy http://127.0.0.1:9000
}
# HTTPS upstream, Caddy's default Host handling
localhost:8444 {
tls internal
reverse_proxy https://localhost:9443 {
transport http {
tls_trust_pool file {$HOME}/.local/share/caddy/pki/authorities/local/root.crt
}
}
}
Save two files beside it. check.sh presigns a GET for hello.txt per port, fetches it with curl and prints the status and S3 error code. check.py lists the bucket with boto3, the AWS SDK for Python, to show an SDK fails the same way.
# Presign a GET for each port, fetch it, then list the bucket with boto3
aws configure set default.s3.addressing_style path
CA="$HOME/.local/share/caddy/pki/authorities/local/root.crt"
for port in "$@"; do
url=$(aws s3 presign s3://my-bucket/hello.txt --endpoint-url "https://localhost:$port" --expires-in 300)
status=$(curl -s --cacert "$CA" -o body.txt -w '%{http_code}' "$url")
code=$(grep -o '<Code>[^<]*' body.txt | cut -c7-)
echo "via $port: status=$status code=${code:--}"
python3 check.py "$port"
doneIts second line writes addressing_style = path to the default profile in ~/.aws/config, and that setting stays after the test.
import os
import sys
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
port = sys.argv[1]
s3 = boto3.client(
"s3",
endpoint_url=f"https://localhost:{port}",
config=Config(s3={"addressing_style": "path"}),
verify=os.path.expanduser("~/.local/share/caddy/pki/authorities/local/root.crt"),
)
try:
resp = s3.list_objects_v2(Bucket="my-bucket")
print(f"sdk via {port}: objects={len(resp.get('Contents', []))}")
except ClientError as err:
print(f"sdk via {port}: error={err.response['Error']['Code']}")Start Caddy, check both sites, and stop it:
caddy start --config Caddyfile > caddy.log 2>&1 && sleep 2
sh check.sh 8443 8444
caddy stop 2> /dev/nullvia 8443: status=200 code=-
sdk via 8443: objects=1
via 8444: status=403 code=SignatureDoesNotMatch
sdk via 8444: error=SignatureDoesNotMatch
Lines 3 and 4 differ by server:
| Server | Line 3 | Line 4 |
|---|---|---|
| MinIO | via 8444: status=403 code=SignatureDoesNotMatch |
sdk via 8444: error=SignatureDoesNotMatch |
| SeaweedFS | via 8444: status=403 code=SignatureDoesNotMatch |
sdk via 8444: error=SignatureDoesNotMatch |
| Garage | via 8444: status=403 code=AccessDenied |
sdk via 8444: error=AccessDenied |
| RustFS | via 8444: status=403 code=SignatureDoesNotMatch |
sdk via 8444: error=SignatureDoesNotMatch |
In our run, SeaweedFS returned 403 SignatureDoesNotMatch through the rewritten Host too, so its gateway checked the signature. That is not its default: the S3 gateway accepts any access key and secret until you configure credentials.[10] On a default install, a 200 does not show that Host is right. Keep header_up Host {hostport} for every HTTPS upstream.
If both ports fail, the client is signing wrong
If port 8443 fails too, look at the client. Check the endpoint, the region and the addressing style (path, virtual or auto in the AWS CLI),[11] then the other causes of SignatureDoesNotMatch. An app that presigns with an internal Docker hostname needs to sign for the public hostname instead.
The fix: header_up Host {hostport}, not {host}
For an https:// upstream, add header_up Host {hostport} inside reverse_proxy. It sends the Host the client signed, port included, so the signatures match again. Caddy’s HTTP placeholders define {host} as the request’s Host header without its port, and {hostport} as “The host and port from the request’s Host header”.
So on a non-default port such as 8446, {host} drops the port and the signature still fails on MinIO, Garage and RustFS. The OpenCloud thread’s fix used {host},[8] which only holds when Host carries no port. Add the fixed site, and the {host} version for comparison, to the Caddyfile:
# HTTPS upstream, Host set back to what the client signed
localhost:8445 {
tls internal
reverse_proxy https://localhost:9443 {
header_up Host {hostport}
transport http {
tls_trust_pool file {$HOME}/.local/share/caddy/pki/authorities/local/root.crt
}
}
}
# The same, with {host}: the port is lost
localhost:8446 {
tls internal
reverse_proxy https://localhost:9443 {
header_up Host {host}
transport http {
tls_trust_pool file {$HOME}/.local/share/caddy/pki/authorities/local/root.crt
}
}
}
caddy start --config Caddyfile > caddy.log 2>&1 && sleep 2
sh check.sh 8445 8446
caddy stop 2> /dev/nullvia 8445: status=200 code=-
sdk via 8445: objects=1
via 8446: status=403 code=SignatureDoesNotMatch
sdk via 8446: error=SignatureDoesNotMatch
Lines 3 and 4 differ by server:
| Server | Line 3 | Line 4 |
|---|---|---|
| MinIO | via 8446: status=403 code=SignatureDoesNotMatch |
sdk via 8446: error=SignatureDoesNotMatch |
| SeaweedFS | via 8446: status=403 code=SignatureDoesNotMatch |
sdk via 8446: error=SignatureDoesNotMatch |
| Garage | via 8446: status=403 code=AccessDenied |
sdk via 8446: error=AccessDenied |
| RustFS | via 8446: status=403 code=SignatureDoesNotMatch |
sdk via 8446: error=SignatureDoesNotMatch |
What MinIO, Garage, RustFS and SeaweedFS returned
Each column is the presigned GET’s status through one site. “Error code” is what the server sent through the default HTTPS site, and a dash means it sent none. MinIO, SeaweedFS and RustFS sent SignatureDoesNotMatch, but Garage sent AccessDenied. A code other than SignatureDoesNotMatch matters if your alerts or retry logic match on it.
How the servers answered:
| Server | HTTP upstream | HTTPS, default | Error code | {hostport} | {host} |
|---|---|---|---|---|---|
| MinIO | 200 |
403 |
SignatureDoesNotMatch |
200 |
403 |
| SeaweedFS | 200 |
403 |
SignatureDoesNotMatch |
200 |
403 |
| Garage | 200 |
403 |
AccessDenied |
200 |
403 |
| RustFS | 200 |
403 |
SignatureDoesNotMatch |
200 |
403 |
Trust the upstream’s certificate instead of turning verification off
With Host restored, it no longer matches the TLS server name Caddy sends upstream, the pairing the 2.11 default avoids.[5] Your options, best first:
- An
http://upstream on loopback or a private network: Host passes untouched, but that hop is plaintext. - An
https://upstream withheader_up Host {hostport}andtls_trust_poolfor an internal CA. Addtls_server_namewhen the certificate does not match the upstream address.[5] - Never
tls_insecure_skip_verify, which Caddy’s docs call “vulnerable to man-in-the-middle attacks” and say “Do not use in production.”[5]
Lines to delete from older Caddyfiles
Some older S3 snippets set header_up Host {upstream_hostport}, the value 2.11 now sets for HTTPS upstreams.[7] On MinIO, Garage and RustFS it breaks signed requests, whatever the upstream’s scheme, so delete it. Copied header_up X-Forwarded-Proto and X-Forwarded-Host lines are not just redundant. Caddy sets them and ignores untrusted incoming values to prevent spoofing, so manual overrides can break trusted_proxies handling.[5]
Behind a CDN or load balancer, list that hop in trusted_proxies inside the global servers option: Caddy trusts no proxies by default[6]. If the hop appends to X-Forwarded-For, as Cloudflare, CloudFront, AWS ALB and HAProxy do, also set trusted_proxies_strict there. Otherwise a client can spoof the left-most IP.[6]
Large uploads through a Caddy reverse proxy for S3
Caddy needs no body-size setting for S3 uploads: it sets no limit[12] unless you add request_body { max_size <size> }, which then answers 413.[13]
The read_body option, a hard limit on the whole upload, defaults to no timeout. In Caddy 2.11.6 and later,[14] including the 2.11.9 we tested, read_body_idle under servers > timeouts aborts an upload that stalls for 1 minute. It resets after every read, so a slow client that keeps sending is fine. write_idle has the same 1-minute default for stalled downloads.[6] Toward the upstream, read_timeout, write_timeout and response_header_timeout have no timeout by default.[5]
If you add a cap against abuse, keep it above the largest single request your clients send. On Amazon S3, one PUT carries up to 5 GB and a multipart part 5 MiB to 5 GiB;[15][16] self-hosted servers set their own limits. This 64 MiB upload, which the AWS CLI sends in parts above its multipart_threshold,[11] goes through the fixed HTTPS site:
caddy start --config Caddyfile > caddy.log 2>&1 && sleep 2
head -c 64M /dev/urandom > big.bin
aws s3 cp big.bin s3://my-bucket/big.bin --endpoint-url https://localhost:8445 \
--ca-bundle "$HOME/.local/share/caddy/pki/authorities/local/root.crt" --no-progress
caddy stop 2> /dev/nullupload: ./big.bin to s3://my-bucket/big.bin
Virtual-hosted buckets need a wildcard certificate
Path-style requests put the bucket in the path (s3.example.com/my-bucket); virtual-hosted requests put it in the hostname (my-bucket.s3.example.com). Path-style needs one hostname and one certificate. Opndrive switches to path-style when you give it a custom endpoint, so one certificate covers it.
Virtual-hosted style needs *.s3.example.com. Caddy manages a wildcard certificate only when the left-most label is the wildcard.[17] Let’s Encrypt issues wildcards only through the DNS challenge[17]. The tls directive’s dns option needs a Caddy build with your provider’s caddy-dns plugin.[9] For a public certificate, replace tls internal below with tls { dns <provider> ... } from the plugin’s docs:
*.s3.example.com, s3.example.com {
tls internal
reverse_proxy http://127.0.0.1:9000
}
Tell the server its domain
A virtual-hosted request carries the bucket name in Host. The server must know its own domain to tell the bucket from the endpoint; each server sets it differently:
| Server | Setting | Note |
|---|---|---|
| MinIO | MINIO_DOMAIN |
the part of Host before the domain is the bucket[18] |
| RustFS | RUSTFS_SERVER_DOMAINS |
must match the Host clients send, including the port if present[19] |
| Garage | root_domain |
the reverse-proxy cookbook also sets public_endpoint[20] |
| SeaweedFS | -domainName on weed s3 |
comma-separated suffixes[10] |
Put the MinIO or RustFS console on its own hostname
Give the web console its own site and hostname, never a subpath of the S3 API, as the RustFS Caddy guide does.[4]
s3.example.com {
reverse_proxy http://127.0.0.1:9000
}
console.example.com {
reverse_proxy http://127.0.0.1:9001
}
On community MinIO, set MINIO_BROWSER_REDIRECT_URL to the console’s public URL, here https://console.example.com, as its docs specify for Console deployments behind a load balancer or proxy.[21]
The RustFS console’s WebSocket upgrades need no extra header rules.[4] A Caddy config reload closes WebSockets immediately unless you set stream_close_delay to delay closing them.[5]
A follow-up post covers when a backend API or a CDN fits better.
References
- Elements of an AWS API request signature
- Authenticating Requests: Using Query Parameters (AWS Signature Version 4)
- Troubleshoot Signature Version 4 signing for AWS API requests
- Caddy, RustFS Documentation
- reverse_proxy (Caddyfile directive)
- Global options (Caddyfile)
- reverseproxy: Set Host to {upstream_hostport} automatically if TLS
- Caddy 2.11.1 breaks OpenCloud
- tls (Caddyfile directive)
- weed/command/s3.go, SeaweedFS
- AWS CLI S3 Configuration
- Nextcloud File Drop limit, Caddy Community
- request_body (Caddyfile directive)
- Release v2.11.6, caddyserver/caddy
- Uploading objects
- Amazon S3 multipart upload limits
- Automatic HTTPS
- MinIO config README
- Virtual-hosted-style requests, RustFS
- Configuring a reverse proxy, Garage
- MinIO web-identity docs
Try Opndrive
Opndrive gives any S3-compatible bucket a Drive-like web interface you host yourself.
See it on GitHub or read the docs.



