0

I want to setup a reverse proxy to 5 web servers. All the requests that the reverse proxy receives will have a unique id (UID) in the http request query string. I have a database that contains the UID -> web server mappings.

I'm not sure if this is reasonably possible. I'd like the reverse proxy do the following: 1. a request comes in 2. check cache for UID, if not found load it from the database 3. forward the request to the appropriate web server

FYI- I can't encode the server id into the UID, since the mapping might change but the uid will not.

Is something like this possible with perlbal or some other tool? I don't mind if I need to do some scripting to make this happen. I'm just not sure what my options are or what other people have done to solve this problem.

any input is greatly appreciated!!!

2
  • Are you looking to serve content directly from the database, or just to determine the server mapping?
    – Jack M.
    Aug 10, 2009 at 19:52
  • You might want to have a look at HA-Proxy and the hdr* criteria. I have not used this myself.. The mappings from uid to server would have to be in the HA-Proxy configuration, not in a database, so this obviously does not apply if it needs to be very dynamic/would require a lot of UIDs. haproxy.1wt.eu/download/1.3/doc/configuration.txt
    – 0x89
    Aug 10, 2009 at 21:05

3 Answers 3

1

What you are looking for is a load balancer. You can buy a hardware load balancer from companies like Citrix and Foundry (we have both) or you can configure an Apache server to do it.

If your backend servers are tomcat I'd look into mod_ajp which I have done a proxy type configuration for.

For configuration details with a regular HTTP proxying load balancer you can get more information here: http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html

You can likely find some good tutorials for your specific operating system and/or product. As for the session logic you may likely have to handle that in your application, storing the sessions in a central database, but it sounds like you are already heading that route.

0

Depending on which platform you're using, this can be done, but with one big catch.

For IIS you have ISAPI_Rewrite, and for Apache you have mod_rewrite. Both will do what you're after, HOWEVER, they, as far as I know, cannot dynamically retrieve their mappings. They read their settings from a text file.

What you can do (and this is what I've done), is create a small program to interface with the database, that every time a record is changed the text file for the rewriter gets re-compiled. When the next request comes through, the rewriting engine loads the latest version and it's all good.

There is, in general, a delay of about 0.5 of a second when updating the records. Not instant, but usually close enough for web work.

0

This is just a theory but it ought to work. You can have apaches mod_rewrite RewriteMap use simple application to do the rewrite. Rewrite each request to something like server1.example.com based on the UID and then use that url for mod_proxy.

Apache feels a bit heavy to use as a reverse proxy, perhaps you can do the same with Varnish or nginx?

You must log in to answer this question.