title: How to set up an Apache 2 reverse proxy with dynamic backend servers?
body: <p>I would like to set up Apache 2 as a reverse proxy using name-based virtual hosts to decide how requests are routed to back-end servers. Simple enough.</p>
  <p>The catch is that these back-end servers may be added and removed in a dynamic fashion. My first idea was to programmatically re-write an Apache configuration file and call <code>apachectl graceful</code> every time a back-end server goes up or down. This does not seem like the correct solution. What is a better way to accomplish this?</p>
  <p>I need to be able to gracefully transfer handling of names over to different back-end servers. For instance, Backend-Server-A might be handling requests for example.com. A monitoring process might decide that Backend-Server-A is stale (too much memory usage, there's new version of the server code to handle example.com, etc). The monitoring process starts Backend-Server-B which will soon handle requests for example.com. Apache should direct any new requests for example.com to Backend-Server-B, but allow any pending requests currently being handled by Backend-Server-A to complete before Backend-Server-A is shut down.</p>
  <p><em>Update</em>: <a href="https://serverfault.com/questions/79390/how-to-set-up-an-apache-2-reverse-proxy-with-dynamic-backend-servers">Posted to Server Fault</a></p>