Load balancing with wildcard domains

Igor Sysoev is at rambler-co.ru
Sun Aug 12 00:05:37 MSD 2007


On Sat, Aug 11, 2007 at 08:26:28PM +0100, Malte Sussdorff wrote:

> 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
>   Malte
> 
> Here is what I tried:
> 
>     upstream test {
>         server 192.192.23.92:80 weight=150;
>         server 192.192.23.93:8000;
>     }
> 
>     server {
>         listen       192.192.23.200:80;
> 
>         # 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/ {
>            proxy_pass http://192.192.23.93:8000;
>             include         /usr/local/nginx/conf/proxy.conf;
>        }

I do not understand your problem, but it seems you should pass proper "Host"
header to backends:

         location / {
             proxy_pass http://test;
+            proxy_set  Host  $host;
             ...


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list