Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a video conversion php script and I want to get it load-balanced the simplest way by having the traffic diverted to various sub-domains which will be hosted on different dedicated boxes.

so basically what needs to be done is to have users redirected to,, and so on whenever the user lands on sequentially.

Pls. suggest how this can be achieved via apache or nginx and what would be a better choice to do so ?

share|improve this question
do you want the users to hit the machines directly, or one box that loadbalances all? – Joris Mar 5 '11 at 19:42
Directly hit the machines. – iTech Mar 9 '11 at 1:26
up vote 0 down vote accepted

You can achieve this with Apache using mod_proxy and mod_balancer_proxy.

If you rely on PHP sessions, read this article:

The apache config is pretty easy:

Given that you run debian:

apt-get install apache2
a2enmod proxy
a2enmod proxy_balancer

go to /etc/apache2/conf.d and create a file.. let's call it load-balancer. Put this in it:

ProxyPass / balancer://lbcluster/
ProxyPassReverse / balancer://lbcluster/ # The trailing slash is important!
ProxyPreserveHost On # This will preserce the host header for the backend servers

<Proxy balancer://lbcluster>

And you should be good to go :)

Fire up your browser and read some of the Apache docs for knowledge on fine tuning to your needs.

share|improve this answer

Using nginx you can try this:

http {
  upstream mydomain {

  server {
    listen 80;
    location / {
      rewrite ^(.*)$ http://mydomain/$1 break;

Never tested it so YMMV.

share|improve this answer
And what would be the apache directives to achieve this ? – iTech Mar 6 '11 at 2:26
There's mod_proxy_balancer but I am not sure if it will do what you want. – coredump Mar 6 '11 at 2:32

Your Answer


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.