Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm using HAProxy to set a cookie when you visit and redirects to .

The purpose of this is to offer a way to visit a development version of the site instead of the production site, while keeping everything else the same.

The pertinent config line looks something like this:

frontend webfarm
    acl acl_dev path_end /dev

    redirect location / code 302 set-cookie SERVERID=live03 if acl_dev

    default_backend default_farm

Now, instead of redirecting to the root domain, I'd just like to strip off the /dev path. So if I went to it would set the cookie and redirect to

Is this possible with HAProxy, or would I need to use mod_rewrite in the apache backend server?

Note: I don't need a mod_rewrite rule, just looking for whether this is possible in HAproxy.

share|improve this question
up vote 3 down vote accepted

You can do URL rewriting and HTTP headers manipulation (add, modify, and remove headers).

However, the haproxy documentation states that this is not encouraged and your setup should work (without reconfiguration) with and without haproxy running between your clients and your real servers. Following this recommendation, it will be better to use apache mod_rewrite.

share|improve this answer

You can do this with the 'reqrep' or 'reqirep' commands:

reqrep ^([^\ ]*)\ (.*)/dev \1\ /\2 if acl_dev
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.