Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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?

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

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.

share|improve this answer

Your Answer

 
discard

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.