How to Set Up Load Balancer with IP-Based Routing in Cloudflare?

What is the name of the domain?

What is the issue you’re encountering

Hello Cloudflare Community, I need help setting up a Load Balancer to route traffic based on the user’s IP address. Here’s what I’m trying to achieve: I have two servers: Production server with a specific IP address Test server with a different IP address My goal is to have all users access the Production server by default, except for users coming from a specific IP address. Users from this IP should be routed to the Test server. I’ve looked into Traffic Steering options, but I’m not sure which one to choose, and I’m wondering if Custom Rules would be the best approach for this. Could anyone provide guidance on setting up IP-based routing for this scenario? Thanks in advance for your assistance!

Origin Rules would be an ideal choice to route based on the incoming source IP, but you will need Enterprise to get access to Host header and DNS record overrides.

Alternatively, you could try Custom load balancing rules, as ip.src field is available there to match on requests.

If you’re more comfortable with code, you can also use Snippets to configure the same logic using JavaScript. Here is an example to get you started.