AWS WAF URI regex don't match

1

Hi, I created a Web ACL with one rule to allow traffic only on some enpoint, and the default ACL action is to block requests that don't match the rule.

## Rule
Field to Match: URI Path
Regular Expression: /(account|category|post)/ 
Action: ALLOW

##  Default web ACL action for requests that don't match any rules
Action: BLOCK

The problem is that the rule match only path with two or more segments, but don't match path with 1 segment.

http://api.example.com/account/foo/bar     => MATCH - ALLOW
http://api.example.com/account/foo?bar=baz => MATCH - ALLOW
http://api.example.com/account/foo         => MATCH - ALLOW

http://api.example.com/account             => DON'T MATCH - BLOCK
http://api.example.com/account?foo=bar     => DON'T MATCH - BLOCK

What's wrong? I would like the rule matches also path with 1 segment. Thanks in advance

질문됨 2년 전2438회 조회
1개 답변
3

Your regex ends with "/" so the last two URLs will not match because "account" in these URL does not end with "/"

Can you try with "/(account|category|post)"?

Thanks

profile pictureAWS
답변함 2년 전
  • Uh really? I'm using "/" as a delimiter of the regex. Anyway now it works

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠