Controlling access via HAProxy

If you want to limit access through HAProxy (similar to Apache Access Control directives, or firewall rules), you can add code like the following 1

    acl goodguys src
    acl badguys  src
    tcp-request content accept if goodguys
    tcp-request content reject if badguys
    tcp-request content reject

You can test your haproxy configuration with the -c option

sudo haproxy -f /etc/haproxy/haproxy.cfg -c

Configuration file is valid

if no problems are detected, and can be used even on a running haproxy.