Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: <AFaller <at> excelsior.edu>
Subject: Re: Rule 960903 - content encodings
Newsgroups: gmane.comp.apache.mod-security.user
Date: Tuesday 15th July 2008 17:57:52 UTC (over 8 years ago)
>   # Define a "nodeflate" filter that does nothing.  Mostly untested.
>   #  This uses the mod_ext_filter (external filter) module to
>   #  setup a filter that does nothing since the enableenv
>   #  environment variable will never be set, which allows you to
>   #  overwrite the FilterProvider below with this "nodeflate"
>   #  filter based on the content type of responses that you do
>   #  not want to deflate.
>   ExtFilterDefine nodeflate mode=output \
>                             cmd=/bin/true \
>                             enableenv=SomeVarThatWillNeverBeSet
> 
> 
>   SetOutputFilter DEFLATE
> 
>   # Netscape 4.x has some problems...
>   BrowserMatch ^Mozilla/4 gzip-only-text/html
>   # Netscape 4.06-4.08 have some more problems
>   BrowserMatch ^Mozilla/4\.0[678] no-gzip
>   # IE is ok, but looked like Netscape, so we reset it
>   BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
> 
>   # We need to force compression since we will remove the
>   # request Content-Encoding/TE headers which mod_deflate
>   # looks for.
>   SetEnvIfNoCase Accept-Encoding gzip force-gzip
>   SetEnvIfNoCase TE gzip force-gzip
> 
>   # Disable compression from backend
>   RequestHeader unset Accept-Encoding
>   RequestHeader unset TE
> 
>   # Skip images based on extension
>   SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
> 
>   # Make sure caching still works
>   Header append Vary User-Agent env=!dont-vary
> 
>   # Setup the filter to compress the response if we saw
>   # an Accept-Encoding/TE header and marked it as force-gzip
>   FilterDeclare compress CONTENT_SET
>   FilterProvider compress deflate env=force-gzip =1
> 
>   # Overwrite the "deflate" filter with the "nodeflate"
>   # for various content types so they will not be compressed.
>   # This is done as a hack because there is no way to
>   # use more than one condition with FilterProvider above.
>   FilterProvider compress nodeflate Content-Type $image/jpeg
>   FilterProvider compress nodeflate Content-Type $image/gif
>   FilterProvider compress nodeflate Content-Type $image/png
> 
>   FilterProtocol compress "change=yes"
>   FilterChain compress
> 
> 
> It is a bit of a hack, but I hope that it at least points you in the
> right direction.

It might be a bit of a hack, but I think its great. I'm trying to get it 
to work, and its very close i think (I copied exactly what you above, 
changing the env variable in the ExtFilterDefine line) - however I'm 
getting the following in my logs:

[Tue Jul 15 13:49:44 2008] [error] [client xx.xx.xx.xx] couldn't find 
definition of filter 'compress', referer: https://........
[Tue Jul 15 13:49:44 2008] [notice] child pid 865 exit signal Segmentation 
fault (11)

and anything that matches those content types (jpeg,gif,png) doesn't 
display at all (nothing is returned from the proxy). If I comment out the 
FilterProvider compress nodeflate lines, the errors go away, but then the 
images are compressed.

So, am I having issues with the nodeflate Filter?  It seems to work if I 
just try using it via: SetOutputFilter nodeflate

Thanks, Al
 
CD: 4ms