Re: [squid-users] Modifying error Responses.

From: Amos Jeffries <squid3@dont-contact.us>
Date: Mon, 04 Feb 2008 23:39:50 +1300

Krist van Besien wrote:
> Hello all,
>
> I need a way to modify the body of a response when a server responds
> with an error code. I have a suspicion that this may be possible with
> squid, but I'm getting a bit confused by the terse documentation.

Which documentation?

>
> First a bit of background to better understand the problem.
>
> We run a website that serves content for mobile phones. This content
> resides on several backend servers, most of them live with partners
> who provide our content. We have an "aggregator" that accepts requests
> from mobile phones, and then in turn requests the content form one or
> more backend servers. The content these backends deliver is xml, and
> this xml gets transformed by our aggregator in to something a mobile
> phone can display. We access these backends through a squid proxy to
> have some caching.
>
> Our problem is that sometimes the backend sends an error (404, 500
> etc..) without a properly formed xml body. This causes a thread on our
> aggregator to block until a timeout is reached. As a result a problem
> on a backend can lead to resource depletion on our aggregator.
>
> On possible solution would be to modify error responses. We want to
> tack our own xml response body in to any errror response we get from
> a backend.
>
> I've done some reading, and came across ICAP, eCam and clientstreams.
> From the little documentation that is available i'm not sure how to
> attack this problem.
> - I only want to modify http responses when the backend server sends
> an error code (4xx, 5xx).
> - I only want a simple modification. Basically swap out whatever body
> in the response with our own.
> - We currently use squid 2.6. We could move to 3.0 if needed.
>
> Any suggestions as to what the best way to solve our problem would be
> are welcome.

You will likely need to move to squid-3 to get this behaviour within squid.

If you wish to use squid for this any of those three ways you mention
above would be possible approaches.
ICPA and ClientStreams are available in 3.x, eCAP is largely on the
drawing board still. Contact squid-dev if you would be interested in
sponsoring any of that development.

In Squid-3 there may also be a config hack to configure a simple error
response replacement:

   acl PageReplace http_status 404 500
   deny_info http://.../custom_error_content.xml PageReplace
   http_reply_access deny PageReplace

Amos

-- 
Please use Squid 2.6STABLE17+ or 3.0STABLE1+
There are serious security advisories out on all earlier releases.
Received on Mon Feb 04 2008 - 03:39:44 MST

This archive was generated by hypermail pre-2.1.9 : Sat Mar 01 2008 - 12:00:04 MST