cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

🐛 Wrong ingress rule chosen

Open regnaio opened this issue 2 years ago • 1 comments

Using the latest version: 2023.2.1

Suppose you have 2 services:

  • Service 1 serves content for /aaa
  • Service 2 serves content for /bbb/aaa/...

This is perhaps an uncommon case when 2 services unaware of each other just happen to share "aaa" in some of their paths

Suppose your ingress rules look like:

- hostname: <HOSTNAME_1>
  path: /aaa
  service: <SERVICE_1>
- hostname: <HOSTNAME_2>
  path: /bbb/.*
  service: <SERVICE_2>

As expected, /aaa is served by ingress rule 1 (Service 1) As expected, /bbb/ccc is served by ingress rule 2 (Service 2)

However, unexpected is that /bbb/aaa/ccc is also served by ingress rule 1 (Service 1)

Somehow, "/aaa" is getting matched to ingress rule 1 despite the path starting with "/bbb". Since ingress rule 1 seems to have priority over ingress rule 2 due to the ordering, ingress rule 1 is chosen incorrectly...

Perhaps, this could be fixed via: https://github.com/cloudflare/cloudflared/blob/master/ingress/rule.go#L55

regnaio avatar Feb 05 '23 06:02 regnaio

Chaika in the Cloudflare Discord channel suggested using regex's "^", e.g. "^/aaa" to only match if path begins with "/aaa"

This works great, though I worry that others may encounter this issue too assuming that "/bbb/aaa" shouldn't match "/aaa"

regnaio avatar Feb 05 '23 08:02 regnaio