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)

OR

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...?

link|improve this question

47% accept rate
feedback

2 Answers

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)$ http://sourceserver.example.com/$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?

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

Pretty sure you can do this with haproxy too, see http://code.google.com/p/haproxy-docs/wiki/MatchingLayer7

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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