We have a slightly irregular web server: it serves user details based on the user's IP address. The user details are stored in several databases; each database stores information about a subset of users. Users have data in only one database. There is one master database which tells you where each user can be found.
Due to external factors, the web server has to be replaced by a dedicated machine for each database. It would be easy to set up a reverse proxy that splits requests between servers. However, the decision which server to forward the request to depends on the entry in the master database.
Is there a reverse proxy server that allows a script to decide which back-end server gets to handle a particular request?
Squid can easily do that with its
url_rewrite_program
andlocation_rewrite_program
parameters.For example, create a Perl script like
and save that as /usr/local/bin/mysquidrewriter. The above script would replace all the foo occurrences in the URL as bar. For the actual SQL stuff you of course need to modify this script. :-)
Then add to squid.conf a line like
When you restart Squid it starts couple of mysquidrewriter processes background and every URL Squid has to serve will be massaged through them. I have done this many times and it works just perfectly.