How to use fastcgi_next_upstream in Nginx

Julien picture Julien · Mar 29, 2011 · Viewed 9.1k times · Source

I'd like to have 1 web server (nginx) and 2 FastCGI instances of the same application as back-end. The idea is to forward requests to second one if the first one is down.

Apparently, I need to use upstream and fastcgi_next_upstream. But I could not find a working example of a nginx.conf file. Does anybody have such example?

Answer

CyberDem0n picture CyberDem0n · Mar 29, 2011

http://wiki.nginx.org/HttpUpstreamModule
http://wiki.nginx.org/HttpFcgiModule

upstream  backend  {
    server   main_backend.server:port1;
    server   backup.server:port2    backup;
}

fastcgi_pass backend;