1
0
Fork 0
docker-easy-haproxy/docs/plugins/cloudflare.md
Joao Gilberto Magalhaes ae6eb1b55a Add detailed plugin documentation for Cleanup, Cloudflare, Deny Pages, IP Whitelist, JWT Validator, and FastCGI plugins
- Added individual markdown files with examples, configuration options, and HAProxy outputs for each plugin.
- Updated `README.md` to link plugin-specific documentation.
- Enhanced `plugins.md` to summarize plugin features and usage.
- Included Docker, Kubernetes, Swarm, and static configuration examples for all plugins.
2025-12-01 13:36:11 -05:00

2.3 KiB

Cloudflare Plugin

Type: Domain Plugin Runs: Once for each discovered domain/host

Overview

The Cloudflare plugin restores the original visitor IP address when requests come through Cloudflare's CDN.

Why Use It

Cloudflare replaces the visitor's IP with its own. This plugin restores the original IP from the CF-Connecting-IP header.

Configuration Options

Option Description Default
enabled Enable/disable plugin true
ip_list_path Path to Cloudflare IP list /etc/haproxy/cloudflare_ips.lst

Configuration Examples

Docker/Docker Compose (Basic)

services:
  myapp:
    labels:
      easyhaproxy.http.host: example.com
      easyhaproxy.http.plugins: cloudflare

Docker/Docker Compose (Custom IP List Path)

labels:
  easyhaproxy.http.plugins: cloudflare
  easyhaproxy.http.plugin.cloudflare.ip_list_path: /custom/path/cf_ips.lst

Kubernetes Annotations

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    easyhaproxy.plugins: "cloudflare"
    easyhaproxy.plugin.cloudflare.ip_list_path: "/etc/haproxy/cloudflare_ips.lst"
spec:
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            backend:
              service:
                name: myapp
                port:
                  number: 80

Static YAML Configuration

# /etc/haproxy/static/config.yaml
plugins:
  config:
    cloudflare:
      enabled: true
      ip_list_path: /etc/haproxy/cloudflare_ips.lst

Generated HAProxy Configuration

# Cloudflare - Restore original visitor IP
acl from_cloudflare src -f /etc/haproxy/cloudflare_ips.lst
http-request set-header X-Forwarded-For %[req.hdr(CF-Connecting-IP)] if from_cloudflare

Important Notes

  • Required: Download Cloudflare IP list from Cloudflare documentation
  • The plugin runs once per domain during the discovery cycle
  • Ensure the IP list file is mounted and accessible to HAProxy