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: help with accept-ranges
Author
Doug22



Joined: 02 Jun 2013
Posts: 57
Location: Houston TX

PostPosted: Fri 18 Oct '13 21:29    Post subject: help with accept-ranges Reply with quote

I'd like to test out putting a damper on serving out partial content. I know this involves doing something like

accept-ranges none

but I frankly don't know where to put that command line! Can I put it in my .htaccess, or does it have to go in my http.conf? This is with 1.1.33.

When I've put that line in my http.conf, even as

Header set Accept-Ranges none

my server won't boot the Apache server. It doesn't like it.

When I put it in .htaccess, and look at my Response Header, it reports that my site is dead.

Aargh. I think I need some very specific instructions!
Back to top
glsmith
Moderator


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

PostPosted: Sat 19 Oct '13 2:54    Post subject: Reply with quote

As in Apache 1.1.33? What is that, from 1986? I don't think you even have the option with 1.x.

Starting with 2.0 (which is still at end of life) you do have the MaxRanges directive.

http://httpd.apache.org/docs/2.2/mod/core.html#maxranges

Looking at the context of the directive, it tells us it can be used server wide, per virualhost or in a directory container. it is not allowed in a .htaccess file.
Back to top
Doug22



Joined: 02 Jun 2013
Posts: 57
Location: Houston TX

PostPosted: Sat 19 Oct '13 17:11    Post subject: Reply with quote

1.3.33 is actually from 2003, on a Mac that is being used as a dedicated server, and can't be upgraded past 10.3. Works great as a server, except for that.

If indeed it is possible to do it in 2.0, you still didn't tell me where to put it, though it's interesting to know that it can't be in .htaccess.

Maybe you're saying that I had the right command in httpd.conf, but 1.3.33 doesn't know what to do with it?
Back to top
glsmith
Moderator


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

PostPosted: Sat 19 Oct '13 19:06    Post subject: Reply with quote

The directive is MaxRanges and yes, 1.3.33 would fail to start because it doesn't know what that directive is.

If you can go 2.0, you may as well go 2.2, or better yet 2.4.

When looking at the Docs, the "Context" in the box below the directive tells you where it can go.

server config = anywhere in httpd.conf outside of <VirtualHost> or <Directory> containers.

virtual host = inside a <VirtualHost> container.

directory = inside a <Directory> container.

htaccess = the directive may be places inside a .htaccess file. These will usually require a override which is then listed last on the next line in the box, if it's say FileInfo, then AllowOverride would need to have FileInfo listed.

AllowOverride FileInfo
Back to top
Doug22



Joined: 02 Jun 2013
Posts: 57
Location: Houston TX

PostPosted: Sat 19 Oct '13 21:40    Post subject: Reply with quote

Thanks. Good to know.

But I'm not sure where that leaves the "accept-ranges" directive. Does "accept-ranges none" not do the job? Is that directive not permitted in 1.3?
Back to top
glsmith
Moderator


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

PostPosted: Mon 21 Oct '13 12:55    Post subject: Reply with quote

Well, if Header set doesn't work, what does the error log say about why it doesn't work?

Header set Accept-Ranges none

works for me in .htaccess on 2.4
AllowOverride must be set to FileInfo for the directory though.
Back to top
Danll



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

PostPosted: Thu 24 Oct '13 1:01    Post subject: Reply with quote

glsmith wrote:
Well, if Header set doesn't work, what does the error log say about why it doesn't work?

Header set Accept-Ranges none

works for me in .htaccess on 2.4
AllowOverride must be set to FileInfo for the directory though.


If I do that, what it says is

"Wed Oct 23 17:54:03 2013] [alert] [client 11.111.111.111] /Users/me/Sites/.htaccess: Invalid command 'Header', perhaps mis-spelled or defined by a module not included in the server configuration"

That's probably 1.3 talking to me.
Back to top
glsmith
Moderator


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

PostPosted: Thu 24 Oct '13 2:22    Post subject: Reply with quote

Well, in 1.3 mod_headers I see "Header" in the directives, line 165
http://svn.apache.org/viewvc/httpd/httpd/branches/1.3.x/src/modules/standard/mod_headers.c?view=markup

So, is mod_headers loaded?
Back to top
Danll



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

PostPosted: Thu 24 Oct '13 4:30    Post subject: Reply with quote

glsmith wrote:

So, is mod_headers loaded?

Sorry, how do I tell and do?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Thu 24 Oct '13 9:55    Post subject: Reply with quote

with httpd -M
Code:

C:\Users\mario\Apache24\bin>httpd -M
Loaded Modules:
 core_module (static)
 win32_module (static)
 mpm_winnt_module (static)
 http_module (static)
 so_module (static)
 actions_module (shared)
 alias_module (shared)
 allowmethods_module (shared)
 asis_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authnz_ldap_module (shared)
 authz_core_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 headers_module (shared)
 include_module (shared)
 isapi_module (shared)
 ldap_module (shared)
 log_config_module (shared)
 lua_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 vhost_alias_module (shared)
 fcgid_module (shared)
 auth_ntlm_module (shared)
 moo2_module (shared)

C:\Users\mario\Apache24\bin>
Back to top
Danll



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

PostPosted: Thu 24 Oct '13 17:51    Post subject: Reply with quote

httpd -M doesn't work

httpd: illegal option -- M
Usage: httpd [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]


But, we're making progress. I uncommented

LoadModule headers_module libexec/httpd/mod_headers.so

and

AddModule mod_headers.c

in my httpd.conf file, restarted Apache, and put

Header set Accept-Ranges none

in my .htaccess, and my Apache seems happy with that. So, um, how do I know it's really not accepting ranges now?
Back to top
glsmith
Moderator


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

PostPosted: Thu 24 Oct '13 20:14    Post subject: Reply with quote

Use something to send a request like Curl and see what the server sends back or if you have Firefox, install the Live HTTP Headers extension. It will show you all the headers the server sends back;

Code:
HTTP/1.1 200 OK
Date: Thu, 24 Oct 2013 19:17:14 GMT
Server: Apache/2.4.7-dev (Win32) OpenSSL/1.0.1e
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=500; includeSubDomains
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Accept-Ranges: none
Content-Length: 800
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Back to top
Danll



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

PostPosted: Thu 24 Oct '13 22:19    Post subject: Reply with quote

Sigh, did curl --head http://x.y.z.net

and got back

machine:~ danll$ curl --head http://x.y.z.net
HTTP/1.1 200 OK
Date: Thu, 24 Oct 2013 20:12:19 GMT
Server: Apache/1.3.33 (Darwin)
Last-Modified: Thu, 18 Aug 2009 18:21:44 GMT
ETag: "32771-7b0-4304d1b8"
Accept-Ranges: bytes
Content-Length: 1968
Content-Type: text/html


No errors recorded.

And I also have a bunch of strings of 206 requests in my log. So I'm still missing something. It's still accepting ranges when I've asked it not to.
Back to top
glsmith
Moderator


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

PostPosted: Thu 24 Oct '13 23:39    Post subject: Reply with quote

Well, it's easy to build 1.3 so I gave it a go.

in .htaccess just using Header set I still got the "bytes" answer as you are observing, so I tried;

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


and it still replied with "bytes" until I restarted Apache.

Code:
HTTP/1.1 200 OK
Date: Thu, 24 Oct 2013 21:35:38 GMT
Server: Apache/1.3.33 (Win32)
Accept-Ranges: none
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html


However, that just lies to the client since the server will still give out partial content. The only way to stop partial content is with MaxRanges in Apache 2.x. IIRC, Darwin is just ancient Macintosh so you might at least be able to compile a newer version of Apache (2.0.65?) on it.

Code:
HTTP/1.1 206 Partial Content
Date: Thu, 24 Oct 2013 21:52:46 GMT
Server: Apache/1.3.33 (Win32)
Accept-Ranges: bytes
Last-Modified: Wed, 22 Feb 2012 00:05:13 GMT
Etag: "0-3a7fbe-4f443139"
Content-Length: 65536
Content-Range: bytes 0-65535/3833790
Keep-Alive: timeout=15, max=90
Connection: Keep-Alive
Content-Type: application/pdf


Edit: I just thought of something else, mod_rangecnt. It is compatible with both Apache 1.3 & 2.x. You would have to build it but it can be configured to allow only one range. The module was developed as a workaround for KillApache which exploited the way Apache handled range headers at the time.

http://people.apache.org/~dirkx/mod_rangecnt-improved/
Back to top
Danll



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

PostPosted: Fri 25 Oct '13 16:03    Post subject: Reply with quote

Hmmm. Well, each time I change my /etc/httpd/httpd.conf, I restart Apache. At least I think I do. My experience is that Apache reads that file only when it is starting up. The way I do it (on a Mac, again), is in SysPrefs to turn off Personal Web Sharing, and then turn it back on.

When I do this, after changing the httpd.conf file, and adding the Unset command into the .htaccess file I still get

Accept-Ranges: bytes
in response to the curl command.

Yes, I probably need to see if/how I can install Apache 2 in 10.3.9.

One other question. I'm a little confused about multiple .htaccess files. I have one in my /user/danll/Sites directory, that controls access to the websites in that Directory. There seems to be another one in /user/danll that I haven't been paying any attention to. What's that second one for? Should I have put

Header set Accept-Ranges none

in that second one as well?? How are the responsibilities of these two .htaccess files different?
Back to top
glsmith
Moderator


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

PostPosted: Fri 25 Oct '13 22:06    Post subject: Reply with quote

the .htaccess file in /user/danll will also affect what is in /user/danll/Sites.

the .htaccess in /user/danll/Sites will not affect anything in /user/danll.

see http://httpd.apache.org/docs/1.3/configuring.html#htaccess
Back to top
Danll



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

PostPosted: Sat 26 Oct '13 4:30    Post subject: Reply with quote

glsmith wrote:
the .htaccess file in /user/danll will also affect what is in /user/danll/Sites.


Well, then if I have an .htaccess in /user/danll, and another one in /user/danll/Sites, are the rules from each just added together, or does one take precedence over the other? If those two files have commands that are contradictory, what .htaccess commands pertain to a site in Sites?
Back to top
glsmith
Moderator


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

PostPosted: Mon 28 Oct '13 18:33    Post subject: Reply with quote

A little trial and error should make this clear, but anything /user/danll/Sites/.htaccess should override what is in /user/danll/.htaccess as far as I know.
Back to top
Danll



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

PostPosted: Mon 28 Oct '13 19:20    Post subject: Reply with quote

Many thanks. I very much appreciate your insights.
Back to top


Reply to topic   Topic: help with accept-ranges View previous topic :: View next topic
Post new topic   Forum Index -> Apache