You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tom Pike <th...@p3international.org> on 2006/11/09 23:59:10 UTC

[users@httpd] mod_ext_filter with proxied content

G'day,

	We have an Apache + Squid + Zope combination running Plone for our main
site on a server located in Hong Kong (http://www.globalhand.org).
Sadly Hong Kong is a few transoceanic links from most of our users (USA
and Europe) so we have employed the services of a CDN to serve most of
our smaller objects; images, JS and CSS to improve page load times.

	It is not possible to specify different domains for objects in Plone eg
have pages served from www.example.com and images from cdn.example.com,
it is an all or nothing approach; all objects have to be served from the
same domain (the base URLs are generated by the Virtual Host Monster).
Fixing this behaviour in Plone is a large undertaking and would require
changing virtually every page template, breaking future compatability
with upgrades or 3rd party products.

	We are looking at the use of mod_ext_filter and sed to dynamically
rewrite the URLs of images, JS and CSS after the page has been rendered
by Zope/Plone but we have struck a few issues.  The filtering works well
when the object is local to Apache (fetched from the local filesystem),
but does not work when the content is proxied (fetched from the
Squid/Zope backends).  It appears that the filters are not applied when
the content is proxied.

	Below is a sanitised section of our configuration file:

ExtFilterDefine rewritecdnurl mode=output intype=text/html \
	cmd="/bin/sed 's/www\.example\.org/cdn\.example\.org/g'"

<IfModule mod_rewrite.c>
	RewriteEngine on

	RewriteRule ^/error/ - [L]
	RewriteRule ^/(.*)
http://localhost:8077/VirtualHostBase/http/%{HTTP_HOST}:80/nav_root/VirtualHostRoot/$1 [L,P]

	SetOutputFilter rewritecdnurl
</IfModule>

	I realise the filter at this point will rewrite every URL on the page,
it it just for testing purposes.  We are running Apache 2.0.59 compiled
from source on CentOS 4.3/4.4.  How does one configure Apache to do
this?  We would be very grateful for any assistance given as we have had
to disable the CDN service until this issue has been resolved.



				Many Thanks,

				Tom Pike

-- 
+------------------------------------------+
| Tom Pike thwpike@p3international.org     |
| P3 International www.p3international.org |
+------------------------------------------+

Re: [users@httpd] mod_ext_filter with proxied content

Posted by Joshua Slive <jo...@slive.ca>.
On 11/9/06, Tom Pike <th...@p3international.org> wrote:

> ExtFilterDefine rewritecdnurl mode=output intype=text/html \
>         cmd="/bin/sed 's/www\.example\.org/cdn\.example\.org/g'"
>
> <IfModule mod_rewrite.c>
>         RewriteEngine on
>
>         RewriteRule ^/error/ - [L]
>         RewriteRule ^/(.*)
> http://localhost:8077/VirtualHostBase/http/%{HTTP_HOST}:80/nav_root/VirtualHostRoot/$1 [L,P]
>
>         SetOutputFilter rewritecdnurl
> </IfModule>

In what context is this placed in the config file?

Does it work with
<Location />
SetoutputFilter rewritecdnurl
</Location>

Joshua.

---------------------------------------------------------------------
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] mod_ext_filter with proxied content

Posted by Tom Pike <th...@p3international.org>.
On Thu, 2006-11-09 at 23:37 +0000, Nick Kew wrote:
> On Thu, 09 Nov 2006 22:59:10 +0000
> Tom Pike <th...@p3international.org> wrote:
> 
> 
> > 	We are looking at the use of mod_ext_filter and sed to
> 
> Ouch!  mod_line_edit will do that for vastly less overhead.
> 
> > dynamically rewrite the URLs of images, JS and CSS after the page has
> > been rendered by Zope/Plone but we have struck a few issues.  The
> 
> In that case, you probably want
> http://www.apachetutor.org/admin/reverseproxies
> 

Many thanks for your help, we discovered our problem.  Our backends were
compressing the bodies of the pages, thus pattern matching does not
work.  The filters were being applied but with no effect.  Disabling
compression on the backends has solved the problem completely.


			Tom

-- 
+------------------------------------------+
| Tom Pike thwpike@p3international.org     |
| P3 International www.p3international.org |
+------------------------------------------+

Re: [users@httpd] mod_ext_filter with proxied content

Posted by Tom Pike <th...@p3international.org>.
On Thu, 2006-11-09 at 23:37 +0000, Nick Kew wrote:
> On Thu, 09 Nov 2006 22:59:10 +0000
> Tom Pike <th...@p3international.org> wrote:
> 
> 
> > 	We are looking at the use of mod_ext_filter and sed to
> 
> Ouch!  mod_line_edit will do that for vastly less overhead.
> 

We are also currently investigating mod_line_edit.  Our problem is not
so much the filters themselves, but getting the body of the page to pass
through the filters after being proxied.  The use of mod_ext_filter and
sed is more a proof of concept.

We are also somewhat wary of using modules that are not part of the
"official" Apache family having been bitten in the past, though I
understand mod_line_edit has been somewhat thoroughly tested in the
wild.

> > dynamically rewrite the URLs of images, JS and CSS after the page has
> > been rendered by Zope/Plone but we have struck a few issues.  The
> 
> In that case, you probably want
> http://www.apachetutor.org/admin/reverseproxies
> 

We have also tried using Proxy setup instead of the mod_rewrite but have
had no luck.  Once again, the problem is not in the filters themselves
but rather the insertion of the filter in the output chain.  We would
really like to stick with mod_rewrite as it gives us a lot more
flexibility.  We will try the setup on the above page though it is very
similar to our previous setup.


			Many thanks for your help,


				Tom Pike

-- 
Tom Pike <th...@p3international.org>
P3 International

Re: [users@httpd] mod_ext_filter with proxied content

Posted by Nick Kew <ni...@webthing.com>.
On Thu, 09 Nov 2006 22:59:10 +0000
Tom Pike <th...@p3international.org> wrote:


> 	We are looking at the use of mod_ext_filter and sed to

Ouch!  mod_line_edit will do that for vastly less overhead.

> dynamically rewrite the URLs of images, JS and CSS after the page has
> been rendered by Zope/Plone but we have struck a few issues.  The

In that case, you probably want
http://www.apachetutor.org/admin/reverseproxies

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.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