Software AG Products 10.5 | Configuring API Gateway | API Gateway Configuration | API Gateway Cluster Configuration | Configuring an API Gateway Cluster | Load Balancer Configuration
 
Load Balancer Configuration
You can use a custom load balancer for an API Gateway cluster. Here you use the load balancer nginx.
On a Linux machine, the load balancer configuration file /etc/nginx/nginx.conf is as follows:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;

upstream apigateway {
server localhost:5555;
server localhost:5556;
server localhost:5557;
}

upstream apigatewayui {
ip_hash;
server server1:9072;
server server2:9072;
server server3:9072;
}

server {
listen 8000;
location / {
proxy_pass http://apigateway;
}
}

}
Use sudo nginx -s reload or sudo nginx -s start to reload or start nginx. In a test environment, the command nginx-debug is used for greater debugging. The load needs to be exposed through the firewall that is protecting the host the firewall is running on.
For accessing API Gateway, Software AG recommends sticky sessions for UI calls. In the sample load balancer configuration file you would see that the API Gateway UI port 9072 is configured with all the three server instances so that the incoming requests are directed to either of the servers.