> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Restrict access by IP on specific page with HAProxy
- URL: https://www.bagz.fr/restrict-access-by-ip-on-specific-page-with-haproxy/
- Published: 2015-06-19T09:51:27.000Z
- Updated: 2015-06-19T09:51:27.000Z
- Author: bgazui
- Tags: Linux, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

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>