Question

Best way to configure Load Balancer with Cloudflare

I need to integrate Cloudflare with my droplets through the Managed Load Balancer provided by DigitalOcean.

This is my current configuration:

Cloudflare

  • WAF Configured
  • Proxy Navigation Enabled (To support WAF)
  • Use of SSL provided by Cloudflare
  • IPv6 Enabled

DigitalOcean

  • Two Droplets with Apache
  • HTTP2 Enabled
  • IPv6 Enabled
  • SSL/HTTPS configured with my own security certificate from my domain
  • Cloud Firewall rules that only allow access on port 80 and 443 by the DO balancer

How should I configure the DigitalOcean load balancer to support this integration, and keep the original IP of the client coming from Cloudflare?

Access Flowchart


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

The setup looks very good. The DigitalOcean Load Balancers will set some HTTP headers that pass the source IP through to your backend servers, like Cloudflare does with X-Forwarded-For, and CF-Connecting-IP headers.

From the Protocol Support section of the docs:

The load balancer sets the X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Port headers to give the backend servers information about the original request.

Hope that this helps! Regards, Bobby