You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Rainer Sabelka <sa...@iue.tuwien.ac.at> on 2008/06/23 19:07:55 UTC

[users@httpd] Use Apache for compression offloading

Hi,

I try to use apache (version 2.2.8 on Ubuntu 8.04) for compression offloading.
What I want to do:
- use mod_proxy to forward all requests to the application server
- use mod_deflate to compress the output
- remove the "Accept-Encondig:" header from the client's request before 
sending it to the application server to avoid that the compression is done 
there.

My frist approach didn't work:

<VirtualHost *:80>
    ServerName www.example.com
    <Proxy *>
         Order deny,allow
         Allow from all
    </Proxy>
    ProxyRequests Off
    ProxyPass / http://realserver:80/
    ProxyPreserveHost on
    RequestHeader unset Accept-Encoding
    SetOutputFilter DEFLATE
</VirtualHost>

The problem with this approach: when I use "RequestHeader unset Accept-
Encoding" then the application server gives me uncompressed output (good) but 
also mod_deflate won't comress the output (bad).

So, this is my second approch, which actually works, but I think is a bit an 
over-kill:

<VirtualHost *:80>
    ServerName www.example.com
    <Proxy *>
         Order deny,allow
         Allow from all
    </Proxy>
    ProxyRequests Off
    ProxyPass / http://localhost:8000/
    ProxyPreserveHost on
    RequestHeader unset Accept-Encoding
    SetOutputFilter DEFLATE
</VirtualHost>

<VirtualHost localhost:8000>
    ServerName www.example.com
    <Proxy *>
         Order deny,allow
         Allow from all
    </Proxy>
    ProxyRequests Off
    ProxyPass / http://realserver:80/
    ProxyPreserveHost on
    RequestHeader unset Accept-Encoding
</VirtualHost>

Here I have 2 instances of apache in proxy-mode connected in series. The first 
one forwards the request to the second one and does the compression of the 
output. The second instance just removes the Accept-Encoding header before it 
forwards the request to the application server.

But I think there must be a an easier solution. Has any body an idea how to 
get this working with only a single instance of apache?

Thanks,
-Rainer

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Use Apache for compression offloading

Posted by André Warnier <aw...@ice-sa.com>.
Hi again.
This is an amendment to my previous answer.

André Warnier wrote:
> 
> 
> Rainer Sabelka wrote:
>> On Tuesday 24 June 2008 09:22:47 André Warnier wrote:
>>> Hi.
>>>
> [...]
> 
>>
>> Hm. I think the check for the Accept-encoding header is hard-coded in 
>> mod_deflate. No matter if I SetOutputFilter DEFLATE conditionally or 
>> unconditionally, the filter won't compress the output as soon as I 
>> unset the Accept-encoding header.
>>
> 
> Hmm. It gets more interesting.
> Then you probably have to be more sneaky still.
> What about this :
> - if there is a request Accept-Encoding header, you unset it, but set a 
> variable
> - you proxy the request
> - you set a first output filter which tests if the variable is set, and 
> if so re-adds an Accept-Encoding header
> - you add the DEFLATE filter
> 
> The above is based on the presumption that you can add output filters in 
> the order you want.  And also that writing (or finding) the first output 
> filter I mention is feasible/easy.
> I would know how to do the above easily using mod_perl (and a bit 
> differently), but I presume there must be other methods, if you don't 
> already use mod_perl.
> 

Looking at the mod_deflate documentation, I see the following note :

Note
There is a environment variable force-gzip, set via SetEnv, which will 
ignore the accept-encoding setting of your browser and will send 
compressed output.

So, maybe the following would work :
- set the DEFLATE output filter
- if (and only if) there is an Accept-Encoding header, unset it but set 
"force-gzip"
- proxy the request
- that's it.

Like (requires mod_setenvif amd mod_headers) :
SetEnvIf Accept-encoding "gzip" force-gzip
Header unset Accept-encoding env=force-gzip
SetOutputFilter DEFLATE

No ?


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Use Apache for compression offloading

Posted by André Warnier <aw...@ice-sa.com>.

Rainer Sabelka wrote:
> On Tuesday 24 June 2008 09:22:47 André Warnier wrote:
>> Hi.
>>
[...]

> 
> Hm. I think the check for the Accept-encoding header is hard-coded in 
> mod_deflate. No matter if I SetOutputFilter DEFLATE conditionally or 
> unconditionally, the filter won't compress the output as soon as I unset the 
> Accept-encoding header.
> 

Hmm. It gets more interesting.
Then you probably have to be more sneaky still.
What about this :
- if there is a request Accept-Encoding header, you unset it, but set a 
variable
- you proxy the request
- you set a first output filter which tests if the variable is set, and 
if so re-adds an Accept-Encoding header
- you add the DEFLATE filter

The above is based on the presumption that you can add output filters in 
the order you want.  And also that writing (or finding) the first output 
filter I mention is feasible/easy.
I would know how to do the above easily using mod_perl (and a bit 
differently), but I presume there must be other methods, if you don't 
already use mod_perl.

André

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Use Apache for compression offloading

Posted by Rainer Sabelka <sa...@iue.tuwien.ac.at>.
On Tuesday 24 June 2008 09:22:47 André Warnier wrote:
> Hi.
>
> I'm not a specialist of that kind of thing, but I'm curious and I just
> wonder about the following kind of scenario :
>
> - In the proxy server, unset the Accept-encoding header, but set another
> non-standard one (or an environment value) that will not be recognised
> by the back-end server
> - condition the SetOutputFilter DEFLATE by this other header/value
> - do the proxying.

Hm. I think the check for the Accept-encoding header is hard-coded in 
mod_deflate. No matter if I SetOutputFilter DEFLATE conditionally or 
unconditionally, the filter won't compress the output as soon as I unset the 
Accept-encoding header.

> The back-end server will not get the Accept-encoding
> header.  Instead it will get the new header you set, but will not react
> to it, so not do compression.
> - but the front-end server still will

> I think that mod_sentenvif and/or mod_rewrite should allow you to do the
> above.  Someone else would have to give you the specifics though.
>
> André
>
> Rainer Sabelka wrote:
> > Hi,
> >
> > I try to use apache (version 2.2.8 on Ubuntu 8.04) for compression
> > offloading. What I want to do:
> > - use mod_proxy to forward all requests to the application server
> > - use mod_deflate to compress the output
> > - remove the "Accept-Encondig:" header from the client's request before
> > sending it to the application server to avoid that the compression is
> > done there.
> >
> > My frist approach didn't work:
> >
> > <VirtualHost *:80>
> >     ServerName www.example.com
> >     <Proxy *>
> >          Order deny,allow
> >          Allow from all
> >     </Proxy>
> >     ProxyRequests Off
> >     ProxyPass / http://realserver:80/
> >     ProxyPreserveHost on
> >     RequestHeader unset Accept-Encoding
> >     SetOutputFilter DEFLATE
> > </VirtualHost>
> >
> > The problem with this approach: when I use "RequestHeader unset Accept-
> > Encoding" then the application server gives me uncompressed output (good)
> > but also mod_deflate won't comress the output (bad).
> >
> > So, this is my second approch, which actually works, but I think is a bit
> > an over-kill:
> >
> > <VirtualHost *:80>
> >     ServerName www.example.com
> >     <Proxy *>
> >          Order deny,allow
> >          Allow from all
> >     </Proxy>
> >     ProxyRequests Off
> >     ProxyPass / http://localhost:8000/
> >     ProxyPreserveHost on
> >     RequestHeader unset Accept-Encoding
> >     SetOutputFilter DEFLATE
> > </VirtualHost>
> >
> > <VirtualHost localhost:8000>
> >     ServerName www.example.com
> >     <Proxy *>
> >          Order deny,allow
> >          Allow from all
> >     </Proxy>
> >     ProxyRequests Off
> >     ProxyPass / http://realserver:80/
> >     ProxyPreserveHost on
> >     RequestHeader unset Accept-Encoding
> > </VirtualHost>
> >
> > Here I have 2 instances of apache in proxy-mode connected in series. The
> > first one forwards the request to the second one and does the compression
> > of the output. The second instance just removes the Accept-Encoding
> > header before it forwards the request to the application server.
> >
> > But I think there must be a an easier solution. Has any body an idea how
> > to get this working with only a single instance of apache?
> >
> > Thanks,
> > -Rainer
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server
> > Project. See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Use Apache for compression offloading

Posted by André Warnier <aw...@ice-sa.com>.
Hi.

I'm not a specialist of that kind of thing, but I'm curious and I just 
wonder about the following kind of scenario :

- In the proxy server, unset the Accept-encoding header, but set another 
non-standard one (or an environment value) that will not be recognised 
by the back-end server
- condition the SetOutputFilter DEFLATE by this other header/value
- do the proxying.  The back-end server will not get the Accept-encoding 
header.  Instead it will get the new header you set, but will not react 
to it, so not do compression.
- but the front-end server still will

I think that mod_sentenvif and/or mod_rewrite should allow you to do the 
above.  Someone else would have to give you the specifics though.

André


Rainer Sabelka wrote:
> Hi,
> 
> I try to use apache (version 2.2.8 on Ubuntu 8.04) for compression offloading.
> What I want to do:
> - use mod_proxy to forward all requests to the application server
> - use mod_deflate to compress the output
> - remove the "Accept-Encondig:" header from the client's request before 
> sending it to the application server to avoid that the compression is done 
> there.
> 
> My frist approach didn't work:
> 
> <VirtualHost *:80>
>     ServerName www.example.com
>     <Proxy *>
>          Order deny,allow
>          Allow from all
>     </Proxy>
>     ProxyRequests Off
>     ProxyPass / http://realserver:80/
>     ProxyPreserveHost on
>     RequestHeader unset Accept-Encoding
>     SetOutputFilter DEFLATE
> </VirtualHost>
> 
> The problem with this approach: when I use "RequestHeader unset Accept-
> Encoding" then the application server gives me uncompressed output (good) but 
> also mod_deflate won't comress the output (bad).
> 
> So, this is my second approch, which actually works, but I think is a bit an 
> over-kill:
> 
> <VirtualHost *:80>
>     ServerName www.example.com
>     <Proxy *>
>          Order deny,allow
>          Allow from all
>     </Proxy>
>     ProxyRequests Off
>     ProxyPass / http://localhost:8000/
>     ProxyPreserveHost on
>     RequestHeader unset Accept-Encoding
>     SetOutputFilter DEFLATE
> </VirtualHost>
> 
> <VirtualHost localhost:8000>
>     ServerName www.example.com
>     <Proxy *>
>          Order deny,allow
>          Allow from all
>     </Proxy>
>     ProxyRequests Off
>     ProxyPass / http://realserver:80/
>     ProxyPreserveHost on
>     RequestHeader unset Accept-Encoding
> </VirtualHost>
> 
> Here I have 2 instances of apache in proxy-mode connected in series. The first 
> one forwards the request to the second one and does the compression of the 
> output. The second instance just removes the Accept-Encoding header before it 
> forwards the request to the application server.
> 
> But I think there must be a an easier solution. Has any body an idea how to 
> get this working with only a single instance of apache?
> 
> Thanks,
> -Rainer
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org