Skip to content

About

plugin per Traefik che fa whitelist sugli IP contenuti in X-Forwarded-For (o in qualsiasi header impostato)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Traefik Middleware Plugin: ipallowlistheader

Questo plugin implementa una IP Allow List basata su un indirizzo IP preso da un header HTTP, ad esempio X-Forwarded-For o True-Client-IP.
È utile quando Traefik riceve le connessioni attraverso un reverse proxy (come Akamai o Cloudflare) e l'IP sorgente TCP non corrisponde al vero client.


✨ Funzionalità

  • Permette o blocca le richieste in base all'IP reale del client.
  • Legge l'IP da un header configurabile (X-Forwarded-For di default).
  • Supporta CIDR e singoli IP (93.43.64.24/32, 212.31.235.0/24, ecc.).
  • Risponde 403 Forbidden se l'IP non è consentito.

📂 Struttura della cartella

plugins-local/
└── src/
    └── github.com/
        └── stefanod83/
            └── ipallowlistheader/
                ├── go.mod
                ├── ipallowlistheader.go
                ├── .traefik.yml
                └── README.md

⚙️ Configurazione Traefik

Abilitare il plugin in traefik.yml

experimental:
  localPlugins:
    ipallowlistheader:
      moduleName: github.com/stefanod83/ipallowlistheader
      version: v0.1.0

Middleware di esempio

http:
  middlewares:
    admin-allowlist:
      plugin:
        ipallowlistheader:
          headerName: "X-Forwarded-For"
          sourceRange:
            - "93.43.64.24/32"
            - "212.31.235.0/24"

Applicazione al router

http:
  routers:
    wp-admin:
      rule: "Host(\`ebi.sefin.it\`) \&\& PathPrefix(\`/wp-admin\`)"
      service: wordpress-ebi-sefin@docker
      middlewares:
        - admin-allowlist

🛠️ Sviluppo e Debug

Requisiti

  • Go >= 1.21
  • Traefik >= v3.0 con supporto ai local plugins

Compilazione locale (facoltativa)

go mod tidy
go build -v

Log Traefik con debug attivo

--log.level=DEBUG

📜 Licenza

MIT

About

plugin per Traefik che fa whitelist sugli IP contenuti in X-Forwarded-For (o in qualsiasi header impostato)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages