Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have two rails webapps, I have configured one webapp to respond to multiple domains. I have done this by making the corresponding server block in nginx as the default.

Now, I want to make even the other webapp process requests for custom multiple domains, Is there a way to do this using a machine with a single IP address? (I know that I can add an additional IP address and make the other webapp listen on this, but my server is on EC2 so I can't add more IPs.)

Both these webapps know which domains they are supposed to respond to, and there are a lot of domains. Also, the domains which these webapps need to respond to, will be changing. So I can't hardcode them in the nginx config. My server has Ubuntu 10.04.

I've researched a bit into this and I think HAProxy may be able to do this kind of routing. Is it possible for HAProxy ACLs to access something like redis to find the destination of an http request?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

I am not aware of this sort of specific functionality of haproxy, however, haproxy does allow for:

  1. ACLs to read from a file: acl host_list_a hdr_beg(host) -f /etc/haproxy/hostsA
  2. For reloads of the config haproxy -f haproxy.cfg -p /var/run/haproxy-private.pid -sf $(</var/run/haproxy-private.pid).

Therefore, you can probably set up /etc/haproxy/hostA as a list of the hostnames. When you add a hostname, run a command that recreates that file (or something like that, perhaps the file ties into a data structure) and then does a haproxy reload.

That being said this feels a bit hacky, reloading your load balancer often in an automated way feels a bit error prone -- so it is worth figuring out if this is really what you need to be doing. If it is, and you do something like this, you should be sure to program in a lot of error checking and self healing.

share|improve this answer
    
Thank you. I got excited when I saw a *redis*patch in the configs thinking there was some way of using redis, However, it turned out to be *re*dispatch. Interesting, how we read what we want to read. –  Khaja Minhajuddin Feb 8 '12 at 9:39
add comment

Your Answer

 
discard

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.