Search code examples
haproxy

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


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?


Solution

  • 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)