cloudflare-operator icon indicating copy to clipboard operation
cloudflare-operator copied to clipboard

Sort cloudflare ingress fields by hostname to ensure deterministic behaviour

Open cyclingwithelephants opened this issue 8 months ago • 2 comments

It became apparent to me in code review that we don't sort wildcards to the bottom in cloudflared configuration. In my playing with https://github.com/cyclingwithelephants/cloudflare-gateway-controller I had the same problem and came up with https://github.com/cyclingwithelephants/cloudflare-gateway-controller/blob/f4b424488aa5e67eee5ec4bb9e082d26208da8ee/internal/clients/cf/tunnel_config_file.go#L68-L101

I wonder if it's worth implement this or something like it to make behaviour more stable when using wildcards

cyclingwithelephants avatar May 01 '25 11:05 cyclingwithelephants

I wonder how path routing would come into play with this sort.

Also bringing the point I alluded to in the linked PR, moving the wildcard to the fallbackTarget is a good idea.

I don't think we can have more than one wildcard either since cloudflare does not route subdomains?

Edit: https://github.com/adyanth/cloudflare-operator/pull/146#discussion_r2070173768

adyanth avatar May 01 '25 11:05 adyanth

I wonder how path routing would come into play with this sort.

In my implementation the URLs are sorted alphabetically, so I believe that would include path routing

Also bringing the point I alluded to in the linked PR, moving the wildcard to the fallbackTarget is a good idea.

I can only see this working If we can enable full customization of the fallback target (which I'm not sure is possible).

I don't think we can have more than one wildcard either since cloudflare does not route subdomains?

Paid cf tunnels do, it's just a limitation of the free tier that means we can't go beyond *.example.com. If we push for the wildcard being the default route we make this incompatible for paid users

cyclingwithelephants avatar May 01 '25 11:05 cyclingwithelephants