Load balancing with wildcard domains

Malte Sussdorff sussdorff at sussdorff.de
Sat Aug 11 23:26:28 MSD 2007


I have a website that serves *.mysite.com which is translated by the  
webserver into mysite.com/* .

It is working fine with nginx as a reverse proxy and hard load  
balancing based on URL (e.g. all *.mysite.com/images goes to a second  
server), but I need to do proper load balancing using upstream.

Sadly, once I do this, www.mysite.com works like a charm, but any  
subdomain does not. Is there a way of doing this without having to  
specify the subdomains separately (there are around 80.000 of them,  
dynamically adding more each day).

Thanks for your help

Here is what I tried:

     upstream test {
         server weight=150;

     server {

         # Set the max size for file uploads to 1000Mb
         client_max_body_size 1000M;

         # serve the rest of the static files from a different server
         location /resources/  {
              root   /web;
             access_log off;

         location /robots.txt {
              root   /web;

         location / {
             proxy_pass http://pitest;
#            include         /usr/local/nginx/conf/proxy.conf;

         # Get images from dev server
        location /photos/images/ {
             include         /usr/local/nginx/conf/proxy.conf;

More information about the nginx mailing list