你能用 haproxy 将 url 列入白名单吗?

can you whitelist urls with haproxy?

您好,我想在 haproxy 中将某些网址列入白名单,例如

只有foobar.com/mypages/*可以访问。

foobar.com 下的任何其他内容都应被阻止。

haproxy 是否为您提供了这样做的能力?

谢谢, 鲍勃

您可以尝试以下配置以获得所需的结果:

#Will set the ACL if path matches
acl allowed_url path_reg */mypages/*

#Based on the previouslt set ACL , we can reject or allow connections
#Accept/whitelist if matches
tcp_request connection accept if allowed_url
#Reject if not
tcp_request connection reject if !allowed_url

还有其他路径匹配 ACL 指令:Path-directives。使用最适合您的情况。