haproxy limit access to root path for specific ip range, but allow from anywhere for specific subdirectory

Viewed 336

I'm using HA-Proxy version 1.8.19

I want to restrict access from external or allow access only for specific IP Range to my website https://testxy.com/, but want to allow access from anywhere to subfolder https://testxy.com/tempDownload/.

I tried it already with following:

http-request deny if { path -i -m beg / } !{ src 10.10.20.0/24 }

How can I do that?

2 Answers
http-request allow if { path_dir -i /tempDownload } { src 0.0.0.0/0 }
http-request allow if { path_dir -i /xy1 } { src 10.10.20.0/24 }
http-request allow if { path_dir -i /xy2 } { src 10.10.20.0/24 }
http-request deny if { path_dir -i -m beg / } !{ src 10.10.20.0/24 }

This solved my problem (if anyone else has the same question)

I would use the exact match instead of beg path

The -i is here also useless as there is no lower- or upper-case version of / ACL Flags

http-request deny if { path / } !{ src 10.10.20.0/24 }
Related