0

How can I make nginx ignore the If-Range header when reading from a cache? My current configuration is:

location / { proxy_set_header If-Range ""; proxy_cache download; proxy_cache_valid 200 30m; proxy_buffering on; proxy_pass http://s3-eu-central-1.amazonaws.com; } 

I have a legacy client (in hardware, so not changeable) which includes an invalid If-Range header, in a request like

curl -k -H 'if-range: 1234' -H 'Range: bytes=195609-' https://myserver.example/... 

My configuration works great if the cache is empty; the client gets an HTTP 206 response with the desired range. But when nginx fulfills the request from its own cache, it returns the entire file with HTTP 200, instead of just the desired range.

So how do I make nginx send a HTTP 206 response even if the If-Range header does not match? Can I for example rewrite the request and strike/replace the offending request header, or configure the cache to ignore the If-Range request header?

1 Answer 1

0

I had this same issue, and I was able to make nginx completely ignore If-Range using this in my location section:

rewrite_by_lua_block { ngx.req.clear_header('If-Range') }

This obviously requires lua support in your nginx, which I happened to already have.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.