-1

we use Traefik 1.7 as the Ingress-controller on our GKE Kubernetes clusters. Each application has an Ingress that routes incoming HTTP requests to a Varnish service, which either serves the response from cache or routes the request to some nginx/PHP backend applications.

The Varnish pods consist of a Varnish container which listens on port 80 for incoming requests and an app on port 6083 that takes care of mirroring BAN requests to all Varnish replicas in order to purge cache objects from all Varnish replicas. Most BAN requests will come from the internal PHP apps but we also have BAN requests coming from GitLab CI tasks that run externally to that cluster.

We would like to route incoming HTTP requests that have the BAN verb (as opposed to GET, POST, etc.) to port 6083 on the Varnish service, while letting GET, HEAD, POST traffic hit port 80 like normal.

I can't figure out a way to have Traefik route to a different service or port based on the HTTP Verb. Any ideas?

Martijn Heemels
  • 3,529
  • 5
  • 37
  • 38
  • Stack Overflow is a site for programming and development questions. You should probably use another site on the [Stack Exchange network](https://stackexchange.com/sites) for this question. Also see [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. – jww Nov 21 '19 at 17:44

1 Answers1

1

You can use the Method() rule in routing expressions. See https://docs.traefik.io/routing/routers/#rule for more details but from a quick check of the code in Traefik and Mux I see no reason that Method(\"BAN\") shouldn't work.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • Thanks @coderanger. That would work, though it appears to be a Traefik 2-only feature. Traefik 2 switched to using a CRD model, which allows more routing options than a 'classic' Kubernetes Ingress which only allows routing based on Host and paths. I'll take a look at migrating to Traefik 2 since that should work for me and appears to be the future anyway. – Martijn Heemels Nov 27 '19 at 15:21