How can i block traffic with a customer header in a Kubernetes ingress?

Hi All,

I'm trying to block incoming requests through a k8 ingress if a header is present?

I'm looking here: Headers - Traefik but don't see anything obvious.

Following code fails to block and i'm not sure why:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: test-header
spec:
  headers:
    customRequestHeaders:
      X-Script-Name: "http_x_hasura_admin_secret"
    frameDeny: true

Thanks
James

Hello @jamesdhope,

maybe you could block the incoming request by modifing the IngressRoute?

Something like this:

[...]
spec:
  entryPoints:
    - foobar
routes:
  - match: Host(`subdomain.example.invalid`) && (! HeadersRegexp(`key`, `.*`)))
    kind: Rule
    services:
[...]

(disclaimer: I didn't try this out)

Best regards,
Wolfgang