HAProxy 只允许 url 具有特定的后缀
HAProxy only allow url with specific suffix
有没有办法在 haproxy 中只允许给定格式的 URL?
我只想在地址包含特定后缀(在我的例子中是 .png 或 .jpg 或 .gif)时允许连接,如果不包含则用 404 拒绝它。
Haproxy 是否允许正则表达式?
赞:
(myurl).*\.(png|jpg|gif)
你应该可以通过 path_reg
的测试来做到这一点。
http-request deny unless { path_reg \.(png|jpg|gif)$ }
或者,简单地与命名 ACL 中的文字字符串匹配。如果命名 ACL 中的任何规则匹配,则 ACL 匹配。
acl path_ok path_end .gif
acl path_ok path_end .jpg
acl path_ok path_end .png
http-request deny unless path_ok
有没有办法在 haproxy 中只允许给定格式的 URL? 我只想在地址包含特定后缀(在我的例子中是 .png 或 .jpg 或 .gif)时允许连接,如果不包含则用 404 拒绝它。
Haproxy 是否允许正则表达式?
赞:
(myurl).*\.(png|jpg|gif)
你应该可以通过 path_reg
的测试来做到这一点。
http-request deny unless { path_reg \.(png|jpg|gif)$ }
或者,简单地与命名 ACL 中的文字字符串匹配。如果命名 ACL 中的任何规则匹配,则 ACL 匹配。
acl path_ok path_end .gif
acl path_ok path_end .jpg
acl path_ok path_end .png
http-request deny unless path_ok