2017-10-07 73 views
0

有没有办法只允许在haproxy中给定格式的URL? 我想只在地址包含一个特定的后缀(在我的情况下是.png或.jpg或.gif)时才允许连接,如果没有,则拒绝它。HAProxy只允许具有特定后缀的网址

Haproxy是否允许使用正则表达式?

喜欢:

(myurl).*\.(png|jpg|gif) 

回答

1

你应该能够与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 
相关问题