Re: reqrep help

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 21 Jan 2009 20:29:58 +0100


Hi Dave,

On Wed, Jan 21, 2009 at 12:44:53PM -0500, Dave Pascoe wrote:
> Long-time haproxy user...first time poster. Finally ran into a rewrite
> issue I just haven't been able to solve. Seems like it ought to be simple.
>
> Problem: Need to rewrite requests like /foo/favicon.ico and to just
> /favicon.ico
>
> Using this line:
> reqrep ^([^\ ]*)\ /(.*)/favicon.ico \1\ /favicon.ico
>
> results in an HTTP 502 returned.
>
> Just having a mental block today...why would I be getting a 502?

I think I found the reason. reqrep replaces the *whole line* with the new string. So basically, you're replacing lines such as "GET /foo/favicon.ico HTTP/1.0" with "GET /favicon.ico" (without the HTTP version). This becomes HTTP/0.9, and I guess your server simply resets the connection because it does not support it, leading to a 502.

IMHO you should be using :

 reqrep ^([^\ ]*)\ /(.*)/favicon.ico\ (.*) \1\ /favicon.ico\ \3

And yes, I know this is not very convenient ;-)

Cheers,
Willy Received on 2009/01/21 20:29

This archive was generated by hypermail 2.2.0 : 2009/01/21 20:45 CET