Advanced Routing Rule

Hi All,

I have a requirement to route different URL paths to CDN endpoints. Each path hosts a static app.

For example, mydomain.com/assets/* should be served from a CDN endpoint.

and the root path like mydomain.com where we host the services should be forwarded to a cloud load balancer IP.

What is the best way to do it in Cloudflare?

Thanks

When you say CDN endpoint do you mean a CDN other than Cloudflare? Assuming yes…

There are lots of ways you could do this including Workers. With a worker you could just add route to a simple worker script that upstreams to your CDN.

You could also define a Load Balancer in Cloudflare with a default rule to route everything to your Cloud LB and a custom rule to send /assets to the CDN:

You can also do this using Origin Rules but you’d need an Enterprise plan to override the DNS (which is what you’d need to switch between your Cloud LB and CDN):

1 Like

Thanks Simon, I will try these things.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.