Load balancing and proxy for Riak-CS

From the basho.com official website – on their technical documentation – we are recommended to place Riak CS behind a load-balancing or proxy solution. Riak CS should not directly expose to public-facing network interfaces.

Today I have managed to make HAPROXY work together with Riak CS as my load-balancing and proxy.

For detail documentation please refer to this link:

https://docs.basho.com/riakcs/1.4.5/cookbooks/configuration/Load-Balancing-and-Proxy-Configuration/

You can use my configuration as a reference too.

Please do not forget to edit your /etc/haproxy/gip.lst by inserting your allowed IPs


global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 256000
spread-checks 5
daemon

defaults
log global
option dontlognull
option redispatch
option allbackups
no option httpclose
retries 3
maxconn 256000
timeout connect 5000
timeout client 5000
timeout server 5000

frontend riak_cs
bind 192.168.0.100:8080
# Example bind for SSL termination
# bind 10.0.24.100:8443 ssl crt /opt/local/haproxy/etc/data.pem
mode http
option httplog
capture request header Host len 64
acl good_ips src -f /etc/haproxy/gip.lst
block if !good_ips
use_backend riak_cs_backend if good_ips

backend riak_cs_backend
mode http
balance roundrobin
# Ping Riak CS to determine health
option httpchk GET /riak-cs/ping
timeout connect 60s
timeout http-request 60s
server riak-cs 192.168.0.10:8080 weight 1 maxconn 1024 check
server riak2 r1s02.example.com:8081 weight 1 maxconn 1024 check
server riak3 r1s03.example.com:8081 weight 1 maxconn 1024 check
server riak4 r1s04.example.com:8081 weight 1 maxconn 1024 check
server riak5 r1s05.example.com:8081 weight 1 maxconn 1024 check