# Prevent reverse proxy from sending range headers to source server

**URL:** <https://www.ruby-forum.com/t/prevent-reverse-proxy-from-sending-range-headers-to-source-server/244010>\
**Category:** NGINX\
**Created:** [February 5, 2016, 2:38am UTC](https://www.ruby-forum.com/t/prevent-reverse-proxy-from-sending-range-headers-to-source-server/244010 "2016-02-05T02:38:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [February 5, 2016, 2:38am UTC](https://www.ruby-forum.com/t/prevent-reverse-proxy-from-sending-range-headers-to-source-server/244010/1 "2016-02-05T02:38:29Z")

</div>

Hello everyone!

I set up my reverse proxy to cache files stored at AWS S3. I want to  
minimize the amount of traffic generated at AWS.

Many of the files are mp4s. Clients make GET requests with the range  
set. A  
video player may get multiple chunks of a file at once.

How can I have the proxy server NOT send the client’s Range header along  
to  
AWS S3? I want the cached version to be used. The file should only be  
revalidated after the set period of 30 days.

So it seems like I would need something along proxy\_set\_header but  
something  
that unsets the header sent to the proxied server.

E.g. proxy\_set\_header Range NULL

The proxy\_ignore\_headers option won’t take Range.

I appreciate any help.

Posted at Nginx Forum:

> **[Prevent reverse proxy from sending range headers to source server](https://forum.nginx.org/read.php?2,264362,264362#msg-264362)**
>
> Hello everyone! I set up my reverse proxy to cache files stored at AWS S3. I want to minimize the amount of traffic generated at AWS. Many of the files are mp4s. Clients make GET requests with the range set. A video player may get multiple chunks of...

---

<div class="post-metadata">

**Author:** ![FSC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9c0ed/32.png) [@FSC](https://www.ruby-forum.com/u/FSC)\
**Post date:** [February 5, 2016, 2:40am UTC](https://www.ruby-forum.com/t/prevent-reverse-proxy-from-sending-range-headers-to-source-server/244010/2 "2016-02-05T02:40:49Z")

</div>

From the docs (  
[Module ngx\_http\_proxy\_module](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header)):

If the value of a header field is an empty string then this field will  
not  
be passed to a proxied server:

proxy\_set\_header Range “”;

proxy\_ignore\_header is meant to handle response headers, not request  
headers

---

<div class="post-metadata">

**Author:** ![FSC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9c0ed/32.png) [@FSC](https://www.ruby-forum.com/u/FSC)\
**Post date:** [February 5, 2016, 12:34pm UTC](https://www.ruby-forum.com/t/prevent-reverse-proxy-from-sending-range-headers-to-source-server/244010/3 "2016-02-05T12:34:21Z")

</div>

No idea how I missed that. Thank you very much!

Also for people that might find this thread later:

Adding the parameter “updating” to the directive “proxy\_cache\_use\_stale”  
is  
important as well if you want to minimize the traffic the origin server  
generates.

proxy\_cache\_use\_stale updating;  
proxy\_set\_header Range “”;

Posted at Nginx Forum:

> **[Re: Prevent reverse proxy from sending range headers to source server](https://forum.nginx.org/read.php?2,264362,264370#msg-264370)**
>
> Hello everyone! I set up my reverse proxy to cache files stored at AWS S3. I want to minimize the amount of traffic generated at AWS. Many of the files are mp4s. Clients make GET requests with the range set. A video player may get multiple chunks of...

---

<div class="post-metadata">

**Author:** ![FSC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9c0ed/32.png) [@FSC](https://www.ruby-forum.com/u/FSC)\
**Post date:** [February 5, 2016, 2:24pm UTC](https://www.ruby-forum.com/t/prevent-reverse-proxy-from-sending-range-headers-to-source-server/244010/4 "2016-02-05T14:24:41Z")

</div>

Hello!

On Thu, Feb 04, 2016 at 08:38:15PM -0500, FSC wrote:

> revalidated after the set period of 30 days.
> 
> So it seems like I would need something along proxy\_set\_header but something  
> that unsets the header sent to the proxied server.

As already mentioned by Robert, proxy\_set\_header with an empty  
value will prevent a header from being sent to upstream servers.

Note well that when caching is enabled, nginx will not send the  
Range header to upstream servers. It is removed automatically  
along with several other headers, see

> **[Alphabetical index of directives](http://nginx.org/en/docs/dirindex.html)**

: If caching is enabled, the header fields “If-Modified-Since”,  
: “If-Unmodified-Since”, “If-None-Match”, “If-Match”, “Range”, and  
: “If-Range” from the original request are not passed to the proxied  
: server.

That is, there is no need to do anything special with the Range  
header.

–  
Maxim D.

> **[nginx](http://nginx.org/)**
