Antwort: [Mod_gzip] gzipping with apache mod_rewrite
mod_gzip@lists.over.net
mod_gzip@lists.over.net
Tue, 1 Oct 2002 22:17:19 +0200
Hi Robert,
> I've a question on apache (which I am not a guru on :])...
> Given a web-acceleration context (for which I'm using apache 2.0 by
> choice, it's part of a specific development for apache), how can I
> gzip on the fly dynamic responses coming from the origin.
>
> I.e. I've got mod_rewrite [P] rules, grabbing content from a backend
> server that *does not* support gzip itself.
>
> All output mods seem to get ignored when mod_rewrite triggers a [P]
> rule. is there someway to avoid that? Clues/Cluebats/pointers/heck even
> a replacement algorithm for mod_rewrite will do :}.
I am not a mod_rewrite user, but according to my limited
understanding of the URL rewriting I believe that when you
rewrite an URL so that it is going to some other machine
then the Apache that did this forwarding doesn't see the
response - it isn't his job any more to care about what
happens to this request now.
But of course there is the requirement to use some Apache
with compresssion module (be it mod_gzip or mod_deflate)
as a "compression filter" for other machines.
Now I am not an Apache 2.0 user as well, but in Apache 1.3
I am doing this trick using mod_proxy. The principle should
work in Apache 2.0 as well.
Instead of rewriting the request URL, I use mod_proxy as
a reverse proxy, make it forward the request _and_ fetch
the response, like this:
<IfModule mod_proxy.c>
# =======================================================================
ProxyPass /localdir/ http://someserver/somedir/
# =======================================================================
</IfModule>
The foreign server is embedded into my URL space. This is
the way that my Apache will get its hands on the response
as well, and then allow my mod_gzip to actually compress
the response.
(I have once started using mod_rewrite for this case as well,
but I actually don't need it now, and I am happy to no longer
compile mod_rewrite into my Apache binary at all. ;-)
This requires mod_gzip to also care about this content, which
can be a little bit tricky, as mod_proxy's internal "file"
and "uri" values are no great use for mod_gzip configuration
filter rules. But
# =======================================================================
mod_gzip_item_include handler ^^proxy-server$
# =======================================================================
is the magic word in this case, and there we are, compressing
some other web server's content.
(Which in my case isn't even an Apache server, nor do I have
any access to it other than via HTTP ...)
Regards, Michael