:::: MENU ::::

Monthly Archives / June 2015

  • Jun 19 / 2015
  • 0

Restrict access by IP on specific page with HAProxy

Most of time, we are setting only one (or some) IP to be allowed to access to some pages or services. But it can also be necessary sometimes to restrict access of an URL only for one IP (if you are getting some attacks from a hacker for example on some webservice).

You can do that restriction much easily with HaProxy with the following rules:

acl network_restricted src IPADDR
acl restricted_page path_reg REGEX
block if restricted_page network_restricted
  • IPADDR: it will be the IP address you want to restrict access
  • REGEX: a regular expression matching the pages you want to restrict (for example: /mypage/v[1-9]{1}/webservice)

Find the full and official documentation (especially on ACL) here: http://cbonte.github.io/haproxy-dconv/configuration-1.6.html#7

Question ? Contact