Web Development
VERIFIED FIXES

NGINX returns 416 Range Not Satisfiable for resumed downloads when using X-Accel-Mirror to an S3‑compatible backend

Environment

Environment

Ubuntu 22.04 NGINX 1.24.0 using X-Accel-Mirror to proxy internal S3-compatible object store (MinIO vRELEASE-2023), TLS terminated at edge, clients download large files with HTTP Range resume requests

Symptoms

Symptoms

Clients attempting to resume large downloads (Range: bytes=nnn-) receive HTTP/1.1 416 Range Not Satisfiable from NGINX only when X-Accel-Mirror is active; direct GETs to storage return 206/partial content correctly.

Observations

Observations

Access logs show NGINX returning 416 for requests that include Range header; upstream object store responded successfully to identical Range requests when queried directly from the webserver host. X-Accel-Mirror passes a rewritten internal URI to internal location that issues proxy_pass to storage. No byte-range rewrites are configured in NGINX beyond mirror handling.

Already attempted

Already attempted

Restarted NGINX, tested with curl --range from server to storage (works), toggled X-Accel-Mirror on/off (416 appears only with mirror), set proxy_buffering off (no effect), compared request/response headers between direct and mirrored proxied requests.

Question

Question

Why does NGINX return 416 for range-resume only when using X-Accel-Mirror to mirror requests to the S3 backend, and how can I restore proper 206 resume support without disabling mirror behavior?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
maja_mobile Answer
user
Posted 4w ago • 0 confirmations

First check whether the mirror/internal location is forwarding the Range header. Add in that location: proxy_set_header Range $http_range; proxy_set_header Accept-Ranges bytes;. Also temporarily disable buffering there (proxy_buffering off; proxy_max_temp_file_size 0;) and retest; if 206 resumes return, buffering was the issue. Verify the internal URI uses the same key/credentials as your direct test—signed URLs or different hostnames can cause upstream to return metadata that disallows ranges. To roll back, restore proxy buffering and remove the added proxy_set_header if it causes other regressions; if issues persist, reproduce with minimal config on a staging host and escalate to your object-store vendor or NGINX package maintainer.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 4w ago• Trouble ID

Most likely causes

Internal mirror location not forwarding the original Range header to upstream (Range header dropped or replaced) 85%
proxy_buffering or proxy_max_temp_file_size causing NGINX to buffer entire response and invalidate range semantics for subrequests 55%
Upstream object store returns different metadata for internal subrequest URI (missing Accept-Ranges or different Content-Length) due to signed URL or credential differences 40%

Summary

The mirror flow alters how NGINX constructs the proxied request/response lifecycle: X-Accel-Mirror creates an internal subrequest whose headers and range semantics may be lost or adjusted by buffer/proxy settings. Common causes include: the mirror/internal location not forwarding the original Range header, upstream returning Content-Length vs. Accept-Ranges differences for internal requests, or proxy_buffering/byte-range caching interfering with range response formation. Direct storage works, so the defect lies in the mirrored/proxied internal request path and header handling.

Suggested Fixes

Diagnostic step 1
Verify and compare headers for mirrored internal subrequest: add add_header X-Debug-Range $http_range in mirror location and log upstream response headers.
Diagnostic step 2
Ensure the mirror/internal location includes proxy_set_header Range $http_range; proxy_set_header Accept-Ranges bytes; so the Range header is forwarded unchanged.
Diagnostic step 3
Temporarily disable proxy_buffering and proxy_max_temp_file_size in the mirror/internal location and retest to rule out buffering effects.

Continue troubleshooting

Matched from the title, description and tags