Upstream setup with proxy and fastcgi?

Igor Sysoev igor at sysoev.ru
Mon Apr 18 22:00:45 MSD 2011


On Mon, Apr 18, 2011 at 01:45:54PM -0400, TECK wrote:
> Thanks for the reply, Francis.
> Let detail more the scenario, so you understand what I try to do.
> 
> [ 1.localserverip (main load balancer, with nginx and php-fpm installed)
> ]
> |
> ---- + [ 2.localserverip (node with php-fpm installed) ]
> |
> ---- + [ 3.localserverip (node with php-fpm installed) ]
> |
> ---- + [ 4.localserverip (node with php-fpm installed) ]
> 
> A better graphical example can be viewed in this image:
> http://farm6.static.flickr.com/5023/5631528237_9153f0d4a5_o.gif
> 
> Basically, 1.localserverip is the site entrance, where nginx load
> balancing is done.
> Each server (including the 1.localserverip) will have the exact same
> content into /var/www/html directory.
> The served content consist in static (images, cass, js, etc.) and php
> files.
> So if an user access the site, 1.localserverip will pick a node and
> serve the content, based on the load balancing setup:
> upstream proxy {
> server 1.localserverip:8000;
> server 2.localserverip:8000;
> server 3.localserverip:8000;
> server 4.localserverip:8000;
> }
> 
> My goal is to be able to load balance not only the proxy but also the
> fastcgi.
> What would be the configuration like?

It's better to place static files on balancers and to use the following
configuration:

location / {
     root  /var/www/html;
}

location ~ \.php$ {
    fastcgi_pass   php;
    ...
}

There is no sense to transfer static files from other nodes,
the balancer should be able to handle them from local disk.


-- 
Igor Sysoev



More information about the nginx mailing list