大网数据广告活动
服务器运维问答

haproxy acl for url and url parameter

· 52CE 我爱测

I want to create an ACL in haproxy 1.6 that allows a particular url and url parameter ONLY when they both appear at the same time. For example: example.com/url/of/page3?foo=bar I am doing this already in the frontend section of m…

问题原文

原帖链接 · simon · CC BY-SA 3.0

I want to create an ACL in haproxy 1.6 that allows a particular url and url parameter ONLY when they both appear at the same time. For example:

example.com/url/of/page3?foo=bar

I am doing this already in the frontend section of my haproxy config:

acl whitelist path /url/of/page1
acl whitelist path /url/of/page2
acl whitelist path_beg /url/of/page3
block unless whitelist

How do I use url_param in combination with with path in my acl?

已采纳解答

原帖链接 · gxx · CC BY-SA 3.0

  • Not sure which version you're running, but, just as a note: AFAIK, the block directive is deprecated. Using this, gives you:

The 'block' directive is now deprecated in favor of 'http-request deny' which uses the exact same syntax. The rules are translated but support might disappear in a future version.

  • It still works, but it might get removed in the future.

  • Regarding your question:

    • Just set up another ACL:

      acl url_param urlp(foo) bar
      

      This tests the first, and only the first url param against the name foo and the value bar, and evaluates to TRUE or FALSE.

    • So, after this, check for the results via:

      http-request deny unless whitelist url_param
      

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-06-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。