# Disabling file resuming with X-Accel / Removing headers

**URL:** <https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628>\
**Category:** NGINX\
**Created:** [March 6, 2012, 11:57pm UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628 "2012-03-06T23:57:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 6, 2012, 11:57pm UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/1 "2012-03-06T23:57:46Z")

</div>

Hello,

I have a config using fastcgi and different locations

FastCGI is set as internal:  
location ~ .php$ {  
internal;

```
fastcgi_pass 127.0.0.1:9000;

fastcgi_send_timeout 120;
fastcgi_read_timeout 120;

fastcgi_index index.php;
include fastcgi_params;

```

}

Services (just two) are rewritten.  
location /get {  
rewrite ^ /get.php last;  
}

I am using nginx’s X-Accel headers, and I want to disable file  
resuming. That implies:

- suppresing output header “Accept-Ranges: bytes”
- suppresing input header “Range”

I am now trying to do the first. Apparently, headers\_more won’t work  
when put in the location /get, or for location /get.php.  
(more\_clear\_headers ‘Accept-Bytes’;).

There is no luck using Lua either, in many different ways. I even  
tried putting Lua before the fcgi, and it does allow adding headers,  
but not replacing or resetting them. As if this header was set a lot  
later in the process (I think so, because it’s added when X-Accel is  
set internally, therefore after fcgi is done processing).

Anyone have any pointers? I’m running out of ideas now.

Thank you a lot for your time

Adrián

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 7, 2012, 12:13am UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/2 "2012-03-07T00:13:14Z")

</div>

Yesterday Mar 6, 2012 at 23:56 Adri?n Navarro wrote:

> tried putting Lua before the fcgi, and it does allow adding headers,  
> but not replacing or resetting them. As if this header was set a lot  
> later in the process (I think so, because it’s added when X-Accel is  
> set internally, therefore after fcgi is done processing).

Just set max\_ranges to zero:  
[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#max_ranges)

–  
WNGS-RIPE

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 7, 2012, 12:46am UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/3 "2012-03-07T00:46:04Z")

</div>

Thank you everyone for your answers.

max\_ranges 0; works great if set in the main server {} directive.  
Sadly, when put inside a location directive, it will not work. The  
same applies for more\_clear\_headers.

The other thing I’m seeing is that while headers with max\_range for  
the whole directive does return correct headers, chrome still allows  
pausing.

I better get some sleep and keep digging tomorrow.

Thank you, I’ll follow up soon.

On Wed, Mar 7, 2012 at 12:24 AM, Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> fastcgi\_param HTTP\_RANGE “”;  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)  
> –  
> Adrián Navarro / (+34) 608 831 094

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 7, 2012, 12:25am UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/4 "2012-03-07T00:25:00Z")

</div>

On Tue, Mar 06, 2012 at 11:56:32PM +0100, Adrin Navarro wrote:

Hi there,

> I am using nginx’s X-Accel headers, and I want to disable file  
> resuming. That implies:
> 
> - suppresing output header “Accept-Ranges: bytes”
> - suppresing input header “Range”

> Anyone have any pointers? I’m running out of ideas now.

Completely untested, and not a direct answer to “file resuming”, but you  
asked for pointers, so maybe…

If you want a response header from a fastcgi process not to be  
delivered to the client, see fastcgi\_hide\_header, for example at

> **[Module ngx\_http\_fastcgi\_module](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_hide_header)**
>
> The ngx\_http\_fastcgi\_module module allows passing requests to a FastCGI server.

If you want a request header not to be sent to a fastcgi process, set  
the matching parameter yourself to empty:

fastcgi\_param HTTP\_RANGE “”;

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 7, 2012, 6:05pm UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/5 "2012-03-07T18:05:19Z")

</div>

max\_ranges 0; worked well but only at server directive.

I have finally decided to use different server{} entries (subdomains)  
for the different cases.

Thank you

On Wed, Mar 7, 2012 at 12:45 AM, Adrián Navarro [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I better get some sleep and keep digging tomorrow.
> 
> > > - suppresing output header “Accept-Ranges: bytes”
> > 
> > * * *
> > 
> > nginx mailing list  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)
> 
> –  
> Adrián Navarro / (+34) 608 831 094

–  
Adrián Navarro / (+34) 608 831 094

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 7, 2012, 6:37pm UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/6 "2012-03-07T18:37:43Z")

</div>

Hello!

On Wed, Mar 07, 2012 at 06:03:54PM +0100, Adrián Navarro wrote:

> max\_ranges 0; worked well but only at server directive.
> 
> I have finally decided to use different server{} entries (subdomains)  
> for the different cases.

It should work at location level as well, though please make sure  
to specify it in location where response is in fact returned, i.e.  
where your X-Accel-Redirect’s are processed.

Maxim D.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2012, 4:28pm UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/7 "2012-03-09T16:28:29Z")

</div>

Hello!

On Thu, Mar 08, 2012 at 01:03:42AM +0100, Adrián Navarro wrote:

> Where should that be?
> 
> I have a location for php scripts (all to fastcgi) figuring as internal.
> 
> Another one (location /get) which rewrites to the PHP file (therefore  
> only accessible via rewrite, as PHP is internal otherwise).
> 
> A location /get.php won’t work either. I tried using matches inside  
> the fcgi directives to add a parameter but didn’t work either, in any  
> case…

Unless you have anything more specific, this would be “location /”.  
If you don’t have “location /” either (which is not recommended),  
this would be implicit location with a settings set on server level.

From what you say I tend to assume you don’t have “location /”,  
and that’s why it only works at server level for you.

See docs here for details:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)**

> **[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#location)**
>
> This directive appeared in version 1.11.8.

Maxim D.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 8, 2012, 1:05am UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/8 "2012-03-08T01:05:07Z")

</div>

Where should that be?

I have a location for php scripts (all to fastcgi) figuring as internal.

Another one (location /get) which rewrites to the PHP file (therefore  
only accessible via rewrite, as PHP is internal otherwise).

A location /get.php won’t work either. I tried using matches inside  
the fcgi directives to add a parameter but didn’t work either, in any  
case…

On Wed, Mar 7, 2012 at 6:36 PM, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to specify it in location where response is in fact returned, i.e.
> 
> > > max\_ranges 0; works great if set in the main server {} directive.
> > > 
> > > > > Anyone have any pointers? I’m running out of ideas now.
> > > > 
> > > > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > > > Adrián Navarro / (+34) 608 831 094
> > 
> > * * *
> > 
> > nginx mailing list  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Adrián Navarro / (+34) 608 831 094

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2012, 11:37pm UTC](https://www.ruby-forum.com/t/disabling-file-resuming-with-x-accel-removing-headers/217628/9 "2012-03-09T23:37:07Z")

</div>

Hmm, it’s true that there is no location / directive (I think).

In such case, does it mean that I must set one to have these options  
work at other /location (including rewrites) directives?

Thank you

On Fri, Mar 9, 2012 at 4:27 PM, Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> > > > > same applies for more\_clear\_headers.
> > > > > 
> > > > > > On Tue, Mar 06, 2012 at 11:56:32PM +0100, Adrián Navarro wrote:  
> > > > > > Completely untested, and not a direct answer to “file resuming”, but you
> > > > 
> > > > * * *
> 
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Adrián Navarro / (+34) 608 831 094
