I had successfully restricted an URL in my web app to certain trusted IP, using below-mentioned config in haproxy config
acl trusted-ip src -f /etc/haproxy/whitelist.lst
acl protected-page url /abc /abc/
acl allowed-page url /abc/api/
http-request deny if protected-page !allowed-page !trusted-ip
I want all users to access "/abc/api" URL, while "/abc" will be accessible only to Trusted IP. The problem here is if anyone from non-trusted IP enters "/abc?something" the URL "/abc" opens, in order to avoid this, I modified the config to
acl trusted-ip src -f /etc/haproxy/whitelist.lst
acl protected-page url_reg ^(?!\/abc\/api).*$
http-request deny if protected-page !trusted-ip
Now I was able to solve the above-mentioned problem, but the "/abc/api" is not accessible to anyone. Any help will be appreciated.