Skip to content

How to create Nginx Upstream Load Balancer

Taymindis Woon edited this page Sep 27, 2017 · 1 revision

Assumed that you have created 3 instance which bind to port 2005,2006, and 2007,

All you need to do is create a upstream in http block.


http {
...
..
 upstream fastcgi_backend {
      server 127.0.0.1:2005;
      server 127.0.0.1:2006;
      server 127.0.0.1:2007;
     # keepalive 8;
 }

server {
    ...

location /searchMyStuff{
  add_header Allow "GET, POST, HEAD" always;
  if ( $request_method !~ ^(GET|HEAD)$ ) {
    return 405;
  }
  include /etc/nginx/fastcgi_params;
  fastcgi_param FN_HANDLER search_my_stuff;
  fastcgi_pass fastcgi_backend;
      #  fastcgi_keep_conn on;
}


}

Ref: http://nginx.org/en/docs/http/ngx_http_upstream_module.html