Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to rewrite a single path via HAProxy. Without the rule in place, a 404 is returned for the directory page (from an IIS node). Once I add the rule, the page returns a 504 Gateway Timeout after a minute or so.

backend Example_Backend
    balance uri
    reqirep ^([^\ ]*)\ (.*)/directory/?[\ ]    \1\ \2/target.asp\ 
    server Server1 x.x.x.xx4:80 weight 25 check fall 10 rise 2 maxconn 40
    server Server2 x.x.x.xx5:80 weight 25 check fall 10 rise 2 maxconn 40
    server Server3 x.x.x.xx6:80 weight 25 check fall 10 rise 2 maxconn 40
    server Server4 x.x.x.xx7:80 weight 25 check fall 10 rise 2 maxconn 40

Is there anything wrong with the way I'm using reqirep? I have tested using sed to make sure it matches correctly for the following:



Edit: Logs from testing /directory and /directory/

haproxy[25957]: x.x.x.100:50941 [31/May/2011:14:53:24.836] Example_Frontend Example_Backend/Server4 77/0/3/-1/50083 504 194 - - sH-- 1/1/1/1/0 0/0 "GET /directory/ HTTP/1.1"
haproxy[25957]: x.x.x.100:50942 [31/May/2011:14:53:26.124] Example_Frontend Example_Backend/Server4 78/0/5/-1/50087 504 194 - - sH-- 0/0/0/0/0 0/0 "GET /directory HTTP/1.1"
share|improve this question
up vote 1 down vote accepted

Cyril from the HAProxy mailing list pointed out that the regex was removing the HTTP/1.1 and HTTP/1.0 from the request. He suggested the following (which worked):

reqirep ^([^\ ]*)\ (.*)/directory/?\ (.*)       \1\ \2/target.asp\ \3
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.