Reverse Proxy with Load Balancer
This document is aimed at helping the users to configure Reverse Proxy when load balancer is used. To do that:
- Install HA Proxy on each rProxy hosts.
- Configure HA Proxy edit
/etc/haproxy/haproxy.conf
and edit IPs of backends and copy to every rProxy hosts.
Below, there is an example configuration for a possible web application.
See the full list of configuration options online at http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
Global settings
To have these messages end up in /var/log/haproxy.log
you will need to:
- Configure syslog to accept network log events.
This is done by adding the -r
option to the SYSLOGD_OPTIONS
in /etc/sysconfig/syslog
.
- Configure 'local2' events to go to the
/var/log/haproxy.log
file. A line like the following can be added to/etc/sysconfig/syslog
local2.*/var/log/haproxy.log
log 127.0.0.1 local2chroot /var/lib/haproxypidfile /var/run/haproxy.pidmaxconn 4000user haproxygroup haproxydaemon
Turn on stats unix socket:
stats socket /var/lib/haproxy/stats
Common defaults that all the 'listen' and 'backend' sections will be used if not designated in their block.
Defaults:
mode httplog globaloption httplogoption dontlognulloption http-server-closeoption forwardfor except 127.0.0.0/8option redispatchretries 3timeout http-request 10stimeout queue 1mtimeout connect 10stimeout client 1mtimeout server 1mtimeout http-keep-alive 10stimeout check 10smaxconn 3000
Main frontend which proxys to the openiam-ui and openiam-esb backends:
frontend ui *:5000default_backend openiam-uifrontend esb *:5001default_backend openiam-esbfrontend statsbind *:8404stats enablestats uri /statsstats refresh 10s
Round robin balancing between the openiam-ui backends:
backend openiam-uibalance roundrobinoption httpchk GET /idp/actuator/healthhttp-check expect string {"status":"UP"}server openiam-ui-01 <ip-of-ui-1>:8080 checkserver openiam-ui-02 <ip-of-ui-2>:8080 checkserver openiam-ui-03 <ip-of-ui-3>:8080 check
Round robin balancing between the openiam-esb backends:
Backend openiam-esb
balance roundrobinserver openiam-esb-01 <ip-of-esb-1>:9080 checkserver openiam-esb-02 <ip-of-esb-2>:9080 checkserver openiam-esb-03 <ip-of-esb-3>:9080 check
- Restart HA Proxy
systemctl restart haproxy
- Edit
mod_openiam_*.conf
and changeOPENIAM_ESBPath
andOPENIAM_ConfigureBackend
to point to HA Proxy frontends:
OPENIAM_ConfigureBackend = http://localhost:5000OPENIAM_ESBPath = http://localhost:5001
- Edit Content Provider's Application Servers to match HA Proxy UI frontend
http://localhost:5000