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'm looking for a reverse proxy solution which either:

a) Let's me explicitly define which requests go to which servers based on a regex (or some other similar way of defining that certain URL patterns get mapped to certain back-end servers)


b) Supports some sort of hash algorithm for proxying so that requests for a given URL always get mapped to one specific server, and publishes that algorithm so that I can use it in my application to determine which server a given URL will be mapped to.

Anything out there like this? Or do I have to write my own...?

share|improve this question
up vote 2 down vote accepted

As far as full-on web servers with proxy capabilities go, both Apache and nginx would both be capable of satisfying option a.

In Apache, you would want to use mod_rewrite's proxy capability:

RewriteRule /(location[1-5]*\.html)$$1 [P]

In nginx, you'd just use a regex for your location directive - see here

For option B, most proxies that implement a hashing option use the opposite approach; making sure that all the requests from a given client are sent to the same server to maintain session state. Can you go into a little more detail about why that would be desirable?

share|improve this answer
Sweet, that is super helpful. I wasn't even aware Apache could do that with mod_rewrite. Thanks! – Keith Palmer Jr. Mar 2 '11 at 15:52

Pretty sure you can do this with haproxy too, see

The previous serverfault question: choose server backend to some URL with haproxy has an example.

Whether or not this is sensible, I don't know. Probably isn't looking at the other answer and the warning in haproxy's documentation.

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.