I have a farm of IIS servers which provides something akin to domain parking sites, with thousands of domains assigned to the system, and content generated dynamically. I need a load balancing and cacheing solution. My intention is to use Apache 2.2 with mod_cache and mod_proxybalance to accomplish this.

My previous experience with Apache has been rather limited, and usually dealing with only a few name based virtual hosts. I've never implemented load balancing or proxying with it before.

While researching a configuration, i'm left scratching my head over some basic configuration directives that i'm not certain how to configure for this environment. In particular, the apache docs give dire warnings about not configuring ServerName directives properly. In this situation, I'm not sure how to handle this.

The site isn't serving it's own content, but rather cached and proxied content. I can't put every domain name into seperate virutalhost directives. Are directives like ServerName (or other directives that seem to require domain names) even necessary in this situation?


If you would like to propose other solutions, i'm open to them. So far, ngnix has been proposed, but ngnix cannot proxy name based virtual hosts due to it's proxy code only using http 1.0 to the backend servers. I'm also uncertain if it can cache name based virtual hosts.

Varnish looks like a possible cacheing solution, but i would really like something I can host on the same server so I don't need multiple servers for each function.

  • Why is are you choosing Apache over some other proxy/cache/balencer? – Zoredache Sep 22 '10 at 3:30
  • If you have other suggestions, i'd love to hear it. Ignorance of other solutions would be why. – Erik Funkenbusch Sep 22 '10 at 3:32
  • HAProxy for load balancing. And Nginx for caching would be how i would do it. – Geraint Jones Sep 22 '10 at 7:59
  • I don't want to run seperate servers for caching and load balancing if I don't have to. – Erik Funkenbusch Sep 22 '10 at 14:24

If you intend to replace the backend, mod_vhost_alias

Otherwise, if you are just putting caching in front of your existing solution, Varnish or Squid would be better suited. Varnish has built-in support for backend load balancing, health checks, etc. You could also run a pair of ipvs servers in front to load balance and provide 100% uptime to a pair (or more) Varnish servers.

  • No, I won't be replacing the backend. I just need a caching solution and load balancing solution. I've looked a bit at Varnish, but it's pretty sparse in terms of information on it. – Erik Funkenbusch Sep 22 '10 at 14:27
  • Varnish is looking pretty good... got it up and going with minimal configuration and I like the built-in load balancing features. – Erik Funkenbusch Sep 22 '10 at 22:06

Basically, you will need a <VirtualHost *> for each domain, each one complete with its own ServerName and ServerAlias, inside each one you will put the directives related to proxy and cache.

I suggest you to put one domain per file, inside a common dir, and include it all from a main apache file. Most linux distros do that nowadays using directories like Debian/Ubuntu's sites-available and sites-enabled - all the domains are files inside the available dir and simply linked inside the enabled dir to be activated.

And I know that it's not what you asked, but since it's just domain parking have you considered using nginx? It's designed to things like this (front end to receive big hits and serve static/cached/proxied content).

  • That's highly impractical. It's not actually domain parking, it's just more similar to it than not. It's actually a portal system with over 50,000 domain names. I can't even imagine 50,000 vhost entries. The maintenance alone would require.. way too much. Thanks for the tip on nginx. – Erik Funkenbusch Sep 22 '10 at 3:14
  • In checking out the documentation for nginx, it doesn't look like it can handle my specific need. In particular, the proxy function speaks http 1.1 to the client and http 1.0 to the internal servers, which my understanding means you can't forward host headers and thus can't proxy name based virtual hosts – Erik Funkenbusch Sep 22 '10 at 3:35

You might want to take a look at http://httpd.apache.org/docs/2.0/vhosts/mass.html and especially the last paragraph. I've successfully run mass vhosting with mod_rewrite.

  • Yeah, that doesn't work for me because rewriting doesn't help. I need to cache and proxy with host headers. – Erik Funkenbusch Sep 22 '10 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.