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

Say I have 6 web servers behind haproxy. Web servers should provide virtual hosting using apache (apache or nginex does not matter). I would like to be able to specify where the incoming HTTP requests (hitting haproxy) should go based on the virtual host. For instance request should go to web1 and web2 request should go to web1, web2 and web3 request should go to web4 and web5 request should go to web5 and web6 request should go to web3, web4, web5 and web6

The idea is to have a HA, load-balanced shared hosting where users can choose on how many servers, 2 to 6 (in this case). The other important thing is that I want to load_balance sites in some servers not in all servers so I could horizontally scale to accept more customers.

Is it possible? If not do you now an alternative solution?

share|improve this question
up vote 0 down vote accepted

Google sez that defining a bunch of ACLs is the way to go, something like this:

frontend http
    bind *:80

    acl host_site_a hdr(host) -i
    acl host_site_b hdr(host) -i

    use_backend site_a if host_site_a
    use_backend site_b if host_site_b

backend site_a
    server web1 web1:80
    server web2 web2:80

backend site_b
    server web1 web1:80
    server web2 web2:80
    server web3 web3:80

And so on. Extend and flesh out as necessary.

share|improve this answer
I saw I could use nginx and probably will work with https too. With haproxy SSL is a problem, I know people are using stunnel. Thank you – rtacconi Jul 30 '11 at 16:21
I don't like nginx for load balancing, even though I think it's an awesome webserver. Yes, SSL is a problem, but since you've probably got to use separate IP addresses for SSL, you can still use haproxy (and you don't have to use ACLs) if you've got SSL sites in the mix. – womble Jul 30 '11 at 16:23

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.