本示例会阻止来自不在允许列表中的 IP 地址的入站请求(允许列表使用 IP list 定义)。
-
创建 IP list,填入你要允许访问的 IP 地址。
例如,创建一个名为allowed_ips的 IP list,包含一个或多个 IP 地址。有关可接受的 IP 地址格式,请参阅 IP lists。 -
创建自定义规则,阻止不在你所创建列表中的 IP 的请求(本例中为
allowed_ips)。-
When incoming requests match(当传入请求匹配时):
Field(字段) Operator(运算符) Value(值) IP Source Address(IP 源地址) is not in list(不在列表中) allowed_ips如果使用表达式编辑器:
(not ip.src in $allowed_ips) -
Then take action(则执行操作):Block
-
-
(可选)用额外过滤条件更新表达式,例如仅对特定 URI 路径阻止非允许列表中的 IP:
Field(字段) Operator(运算符) Value(值) Logic(逻辑) IP Source Address(IP 源地址) is not in list(不在列表中) allowed_ipsAnd(且) URI Path(URI 路径) wildcard(通配符) /admin/*如果使用表达式编辑器:
(not ip.src in $allowed_ips and http.request.uri.path wildcard "/admin/*")