logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Header Accept-Ranges ?
Author
Danll



Joined: 02 Aug 2013
Posts: 49
Location: USA, Houston

PostPosted: Thu 03 Apr '14 16:13    Post subject: Header Accept-Ranges ? Reply with quote

I'm trying to restrict range requests to my server, to cut down on the 206 requests. Seems like it ought to be easy, right?

I have, at the top of my .htaccess file

Code:
Header set Accept-Ranges none


OK, but
Code:
curl -i localhost
gives me

HTTP/1.1 200 OK
Date: Thu, 03 Apr 2014 14:04:50 GMT
Server: Apache/2.2.26 (Unix) PHP/5.3.28 DAV/2 mod_ssl/2.2.26 OpenSSL/0.9.8y mod_perl/2.0.5 Perl/v5.12.4
Content-Location: index.html.en
Vary: negotiate
TCN: choice
Last-Modified: Tue, 18 Feb 2014 20:45:47 GMT
ETag: "56d99-2d-4f2b45b5254c0"
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html
Content-Language: en

Duh, what? "Accept-Ranges: bytes"? No no no. So give me a hint. What's going on? I tell it no ranges, and it is advertising that it accepts ranges?
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3049
Location: Hilversum, NL, EU

PostPosted: Fri 04 Apr '14 11:11    Post subject: Reply with quote

What happens when :

Header unset Accept-Ranges

?
Back to top
Danll



Joined: 02 Aug 2013
Posts: 49
Location: USA, Houston

PostPosted: Fri 04 Apr '14 15:33    Post subject: Reply with quote

When I replace that .htaccess command with
Code:
Header unset Accept-Ranges

the header is unchanged. It still says

Accept-Ranges: bytes

Now, this is a .htaccess file that I do a lot of stuff with. I know it's being used by the system. Is there something somewhere else that is overriding this Accept-Ranges directive? Nothing I can see in my httpd.conf file that refers to "Ranges".

BTW, I'm assuming when I make this change in my .htaccess file, I don't need to restart Apache to make it take effect.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 04 Apr '14 19:47    Post subject: Reply with quote

Danll, it seems we visited this before, but with Apache 1.3.33. The same however works for me on 2.2, from .htaccess and with mod_headers loaded and on 2.2 did not require a restart.

Code:
Header unset Accept-Ranges
Header set Accept-Ranges none


I get;

HTTP/1.1 200 OK
Date: Fri, 04 Apr 2014 17:27:51 GMT
Server: Apache/2.2.26 (Win32) mod_ssl/2.2.26 OpenSSL/1.0.1f mod_antiloris/0.4.1 mod_geoip/1.2.7a mod_limitipconn/0.23 mod_uptime/0.2.0 mod_security2/2.7.5 mod_fcgid/2.3.7 mod_h264_streaming/2.7.7
Accept-Ranges: none
Content-Length: 818
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html;charset=UTF-8


You may still want to use MaxRanges, it will not change the header but Apache will deliver the entire content of the request which should in turn reduce the 206s in your logs.
Back to top
Danll



Joined: 02 Aug 2013
Posts: 49
Location: USA, Houston

PostPosted: Sat 05 Apr '14 0:58    Post subject: Reply with quote

That is correct. We talked about this a few months ago before I upgraded. In fact, I believe that Apache 1.3.33 didn't even offer the option. But 2.2 is supposed to, and I have it now.

I'm pretty baffled.

I put

Code:
Header unset Accept-Ranges
Header set Accept-Ranges none


at the top of my .htaccess file, and I get

Accept-Ranges: bytes

in my header. So something isn't working. I have to assume that something is overriding this Header command but, for the life of me, I can't find it.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Sat 05 Apr '14 2:23    Post subject: Reply with quote

Maybe you need to clear the cache? Are you sure no other .htaccess further into the directory tree is intervening?

Regardless, if you set MaxRanges to none (has to be done server config, virtual host, directory), Apache will serve the request in it's entirety ignoring any range info the browser sends .. so it is documented. This directive came about due to the range-headers attack back more than a year ago and is in 2.2.21 and up.

Have a look
http://httpd.apache.org/docs/2.2/mod/core.html#maxranges
Back to top
Danll



Joined: 02 Aug 2013
Posts: 49
Location: USA, Houston

PostPosted: Sat 05 Apr '14 5:07    Post subject: Reply with quote

OK, I set
Code:
MaxRanges none

in my httpd.conf file, and restarted Apache. Seems to work now. I now get Accept-Ranges: none in my Header.

That's nice, but I'm not quite sure why
Code:

Header set Accept-Ranges none

in my .htaccess file doesn't do it for the particular directory. This way, Accept-Ranges is set to none systemwide.

Thanks for the help!
Back to top


Reply to topic   Topic: Header Accept-Ranges ? View previous topic :: View next topic
Post new topic   Forum Index -> Apache