Country Code redirects to Origin Pool

Hello,

I am using a Cloudflare geo steering load balancer and have regulatory use case to keep traffic in the region. I have traffic from Europe going to regional pools WEU and EEU and I have traffic from UK going to pop pools for GB (LHR, MAN, EDI), all other traffic goes to the US. This setup works but sometimes traffic with country code GB doesn’t always get directed through the GB pop pools (sometimes it goes through CF in FRA), so I would like to route by country code GB to our origin pool point to the UK. I believe I can do this with a worker script but I am new to using them and could use some assistnance.

I have followed the example here: https://developers.cloudflare.com/workers/examples/country-code-redirect. I tested and it appears to work but I do not want to redirect the URL to a different URL, just redirect the traffic to an origin pool. Is that possible?

I have also see these two posts but they refer to URL redirection:


Thank you for your assistance.

You have basically 2 ways to handle this:

  • Redirect
  • Fetch

Redirect will just redirect the user to the new url.

Fetch will pass the request to your backend, and when the backend respond, it will forward the reponse to the client. It means client only sees Cloudflare. Client is never redirected. But beware, regular workers need to exec in 50ms. Your backend should respond fast. To avoid this time limit, you must subscribe to Unbound Workers .