使用在 Ubuntu 12.04 上运行的 Haproxy 1.5.12
我需要将访问我的网站的权限限制为来自某些 IP 或在请求中具有已定义参数的请求。
因此,例如,以下请求应仅适用于授权 IP:
http://www-test.example.com/page.php
Run Code Online (Sandbox Code Playgroud)
并且应该从任何 IP(包括允许的 IP)满足此请求:
http://www-test.example.com/page.php?devtool=1
Run Code Online (Sandbox Code Playgroud)
我的 ACL 是:
acl is_test hdr(host) -m sub test
acl is_allowed src -f /etc/haproxy/allowed_ips
acl is_devtool urlp(devtool) 1
acl is_devtool hdr_sub(Referer) devtool=1
Run Code Online (Sandbox Code Playgroud)
如果专门使用,它们可以正常工作:
http-request deny if is_test ! is_allowed
Run Code Online (Sandbox Code Playgroud)
或者
http-request deny if is_test ! is_devtool
Run Code Online (Sandbox Code Playgroud)
但是,如果我将它们与 OR 结合使用,我将无法从允许的 IP 访问 URL(反转测试无济于事):
http-request deny if is_test ! is_allowed || is_test ! is_devtool
Run Code Online (Sandbox Code Playgroud)
知道如何做到这一点吗?
谢谢