Search code examples
haproxy

Blocking HTTP methods using HAPROXY


How to construct HAPROXY configuration file to block requests for specific HTTP methods?

We're starting to see a number of attacks using methods that we do not support in our apps. We would prefer to reject the traffic at our load balancers rather than have our apps get bogged down with them.


Solution

  • Try putting this in:

    acl valid_method method GET HEAD
    http-request deny if ! valid_method
    

    this will deny any method that is NOT GET or HEAD. Change it to suit your needs