Run Drupal on multiple web servers behind a load balancer
When running large Drupal installations, you may find yourself with a web server cluster that lives behind a load balancer. The pages here contain tips for configuring Drupal in this setup, as well as example configurations for various load balancers.
In addition to a large selection of commercial options, various open source load balancers exist: Pound, Varnish, ffproxy, tinyproxy, etc. Apache can also be configured as a reverse proxy.
The basic layout you can expect in most high-availability environments will look something like this:
-
Browser ──→ HTTP Reverse Proxy ┌─→
──┼─→
└─→Web server 1
Web server 2
Web server 3
By way of explanation:
- Browsers will connect to a reverse proxy using HTTP or HTTPS. The proxy will in turn connect to web servers via HTTP.
- Web servers will likely be on private IP addresses. Use of a private network allows web servers to share a database and/or NFS server that need not be exposed to the Internet on a public IP address.
- If HTTPS is required, it is configured on the proxy, not the web server.
Most HTTP reverse proxies will also "clean" requests in some way. For example, they'll require that a browser include a valid User-Agent string, or that the requested URL contain standard characters.
In the case of Drupal, it is highly recommended that all web servers share identical copies of the Drupal DocumentRoot in use, to insure version consistency between themes and modules. The best way to achieve this is to use an NFS mount to hold your Drupal files.
Note:
- If you plan to install Drupal on a web server that is accessible from the outside via HTTPS, there's an outstanding issue you'll want to check (#313145: Support X-Forwarded-Proto HTTP header). At this time, Drupal's AJAX callbacks use URLs based on the protocol used at the web server, regardless of the protocol used at the proxy. Your workaround is either this patch, or to avoid relying on AJAX on your site. Unfortunately, the Drupal installer relies on AJAX, so you'll either need to install the patch at the issue above, or install via HTTP instead of HTTPS.
