This plugin is an attempt to implement converter of HTTP protocol to gRPC as a middleware plugin for Traefik. It is useful when you declare router to gRPC backend for gRPC client, and additionally you want to intercept connection with middleware, that do HTTP request to third party services and forward it back to gRPC client. Forward Auth for example.
For development, was used following gRPC specs:
- https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md
- https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md
- https://grpc.github.io/grpc/core/md_doc_statuscodes.html
bodyAsStatusMessage
: if true, middleware try set body (as utf8 string) to grpc status message, if false, grpc status message will be empty. Default is falselogLevel
:info
ordebug
. Default isinfo
- cli as local plugin
--experimental.localplugins.http2grpc=true
--experimental.localplugins.http2grpc.modulename=github.com/v-electrolux/http2grpc
- envs as local plugin
TRAEFIK_EXPERIMENTAL_LOCALPLUGINS_http2grpc=true
TRAEFIK_EXPERIMENTAL_LOCALPLUGINS_http2grpc_MODULENAME=github.com/v-electrolux/http2grpc
- yaml as local plugin
experimental:
localplugins:
http2grpc:
modulename: github.com/v-electrolux/http2grpc
- toml as local plugin
[experimental.localplugins.http2grpc]
modulename = "github.com/v-electrolux/http2grpc"
- docker labels
traefik.http.middlewares.checkAuth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/
traefik.http.middlewares.http2grpcMiddleware.plugin.http2grpc.bodyAsStatusMessage=true
traefik.http.middlewares.http2grpcMiddleware.plugin.http2grpc.logLevel=info
traefik.http.routers.http2grpcRouter.middlewares=http2grpcMiddleware,checkAuth
- yaml
http:
routers:
http2grpcRouter:
rule: host(`demo.localhost`)
service: grpcBackend
entryPoints:
- web
middlewares:
- http2grpcMiddleware
- someForwardAuthMiddleware
services:
grpcBackend:
loadBalancer:
servers:
- url: 127.0.0.1:5000
middlewares:
http2grpcMiddleware:
plugin:
http2grpc:
bodyAsStatusMessage: true
logLevel: info
checkAuth:
basicauth:
users:
- "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"