Skip to content

Header Block is a plugin to block request by headers which regex matched by their name and/or value

License

Notifications You must be signed in to change notification settings

PRIHLOP/headerblock

 
 

Repository files navigation

Header Block

Header Block is a middleware plugin for Traefik to block request by headers which regex matched by their name and/or value

Configuration

Static

experimental:
  plugins:
    headerblock:
      moduleName: "github.com/PRIHLOP/headerblock"
      version: "v0.0.6"

Docker-Compose

      - "--experimental.plugins.headerblock.modulename=github.com/PRIHLOP/headerblock"
      - "--experimental.plugins.headerblock.version=v0.0.6"

Dynamic

http:
  middlewares:
    headerblock:
      plugin:
        headerblock:
          requestHeaders:
            - name: "name"
              value: "value"
          whitelistRequestHeaders:
            - name: "Cf-Ipcountry"
              value: "VN"
          allowedIPs:
            - "1.1.1.1/32, 2.2.2.2/32"
            - "3.3.3.3/32"
            - "4.4.4.4"

Example headerblock.yaml

http:
  middlewares:
    headerblock:
      plugin:
        headerblock:
          requestHeaders:
            - name: "User-Agent"
              value: "MJ12bot"
            - name: "User-Agent"
              value: "Amazonbot"
            - name: "User-Agent"
              value: "SemrushBot"
            - name: "User-Agent"
              value: "Applebot"
            - name: "User-Agent"
              value: "AhrefsBot"
          whitelistRequestHeaders:
            - name: "Cf-Ipcountry"
              value: "VN"
          allowedIPs:
            - "1.1.1.1/32, 2.2.2.2/32"
            - "3.3.3.3/32"
            - "4.4.4.4"

Example docker-compose.yml

      # Settle the ports for the entry points
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web-secure.address=:443"
      - "--entrypoints.web-secure.http.middlewares=headerblock@file${TRAEFIK_PLUGINS:-}"
      - "--experimental.plugins.headerblock.modulename=github.com/PRIHLOP/headerblock"
      - "--experimental.plugins.headerblock.version=v0.0.6"

About

Header Block is a plugin to block request by headers which regex matched by their name and/or value

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 97.8%
  • Makefile 2.2%