Nginx conf sample for load balancing with many servers

From Koha Wiki
Jump to navigation Jump to search

If you want to use Koha for clustered environment, nginx can be one of the solutions for multiple servers. This can be used for load balancing and link forwarding.

We share a configuration file for nginx for many servers.

This is the first and quick share for conf file from our past installations. There may need some editing.


server {
	listen *:8081;
	server_name localhost;
	root /var/www/html/maint;
	try_files = $uri @missing;
	location @missing {
		rewrite ^ $scheme://$host/index.html permanent;
	}
 }
upstream koha_opac {
 #ip_hash;
 server 192.168.110.11:80;
 server 192.168.110.12:80;
 server 192.168.110.13:80;
 server localhost:8081 down;
}

upstream koha_intranet {
 #ip_hash;
 server 192.168.110.11:8080;
 server 192.168.110.12:8080;
 server 192.168.110.13:8080;
 server localhost:8081 down;
}

upstream koha_statistics {
  server 200.1.1.12:8080;  <- Real IP maybe
}

server {
  listen *:80;
  server_name koha.devinim.com.tr;
  location / {
  
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

   proxy_pass http://koha_opac;
  }
}

server {
  listen *:8080;
  server_name koha.devinim.com.tr;

  proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


  location /cgi-bin/koha/statistics/stats-home.pl {
       proxy_pass http://koha_statistics;
   }

   proxy_pass http://koha_intranet;
   }
 }