No description
  • Go 95.1%
  • Dockerfile 4.9%
Find a file
Martin Riedl d620c036f2
All checks were successful
Build / Build (push) Successful in 52s
fix: duplicate origin ip in forwarded header
traefik automatically appends the origin ip
2026-07-11 15:57:22 +02:00
.forgejo/workflows feat: automatic push to codeberg 2026-07-10 16:50:00 +02:00
.gitignore feat: initial check in 2026-07-10 15:44:47 +02:00
.releaserc ci: automatic release configuration 2026-07-10 15:49:21 +02:00
.traefik.yml feat: initial check in 2026-07-10 15:44:47 +02:00
Dockerfile feat: initial check in 2026-07-10 15:44:47 +02:00
go.mod feat: initial check in 2026-07-10 15:44:47 +02:00
LICENSE feat: initial check in 2026-07-10 15:44:47 +02:00
middleware.go fix: duplicate origin ip in forwarded header 2026-07-11 15:57:22 +02:00
README.md feat: initial check in 2026-07-10 15:44:47 +02:00

Traefik Plugin — Cloudflare

This Traefik plugin corrects X-Forwarded-* headers for requests coming through Cloudflare.

When a request arrives from Cloudflare, the plugin rewrites X-Forwarded-For and X-Forwarded-Proto to reflect the real visitor's address and protocol. To avoid trusting arbitrary sources, the request is first verified against Cloudflare's IP ranges, as recommended by Cloudflare.

Note: Cloudflare's IP ranges are hardcoded in the plugin. This means no outgoing internet connection is required at runtime. However, the IP list may become outdated if a new version of the plugin is not released after Cloudflare changes their ranges.

Mirror

The original content is stored at git.martin-riedl.de and mirrored to Codeberg.

Installation

Since Traefik allows only public plugins from GitHub, we need to use the workaround of so-called local plugins.

For the helm deployment:

  1. Add this project as an init container. This copies the plugin files into a volume (emptyDir).

    deployment:
      initContainers:
        - name: install-plugin-cloudflare
          image: git.martin-riedl.de/martinr92/traefik-plugin-cloudflare:v1.x.x # use latest version
          command: ["sh", "-c", 'cp -rv "/plugindata/." "/plugin-mount/"']
          volumeMounts:
            - name: plugin-cloudflare
              mountPath: /plugin-mount
      additionalVolumes:
        - name: plugin-cloudflare
          emptyDir: {}
    
  2. Declare the local plugin

    experimental:
      localPlugins:
        cloudflare:
          moduleName: git.martin-riedl.de/martinr92/traefik-plugin-cloudflare
          type: localPath
          volumeName: plugin-cloudflare
          mountPath: /plugins-local/src/git.martin-riedl.de/martinr92/traefik-plugin-cloudflare
          subpath: plugin