Grpc Condition

The grpc condition predicate gates a filter on whether the request carries gRPC, classified from the content-type header alone (application/grpc, application/grpc+proto, application/grpc+json, or any other application/grpc+)

Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.

Category: Setup-dependent integration
Task: The grpc condition predicate gates a filter on whether the request carries gRPC, classified from the content-type header alone (application/grpc, application/grpc+proto, application/grpc+json, or any other application/grpc+)

Prerequisites: The external service, credentials, or certificates referenced by this configuration.

Run it: Use ghcr.io/praxis-proxy/praxis:0.7.2 and follow the first reverse-proxy tutorial to mount and start the configuration.

This configuration comes from the selected release. The example has not been run here; external services are not bundled.

Download the source file.

# gRPC Condition Predicate
#
# The `grpc` condition predicate gates a filter on whether the request
# carries gRPC, classified from the `content-type` header alone
# (`application/grpc`, `application/grpc+proto`, `application/grpc+json`,
# or any other `application/grpc+<codec>`).
#
# The predicate reads the header directly, so it needs no `grpc_detection`
# filter ahead of it and does not depend on filter ordering. Use
# `when: {grpc: true}` to run a filter only for gRPC, `unless: {grpc: true}`
# (or `when: {grpc: false}`) to run it only for everything else.
#
listeners:
  - name: default
    address: "127.0.0.1:8080"
    filter_chains:
      - main

filter_chains:
  - name: main
    filters:
      # Tag only non-gRPC responses: gRPC carries its outcome in
      # trailers, so response headers added here would be pointless.
      - filter: headers
        conditions:
          - unless:
              grpc: true
        response_set:
          - name: "X-Traffic"
            value: "http"

      # gRPC traffic terminates here instead of reaching the backend.
      - filter: static_response
        conditions:
          - when:
              grpc: true
        status: 200
        body: "grpc-only"

      - filter: router
        routes:
          - path_prefix: "/"
            cluster: backend

      - filter: load_balancer
        clusters:
          - name: backend
            endpoints:
              - "127.0.0.1:3000"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends