{"id":21235998,"url":"https://github.com/lddl/traefik-grpc-reverse-proxy","last_synced_at":"2026-05-20T09:31:46.101Z","repository":{"id":98202985,"uuid":"475132305","full_name":"LdDl/traefik-grpc-reverse-proxy","owner":"LdDl","description":"Reverse proxy gRPC via Traefik","archived":false,"fork":false,"pushed_at":"2022-04-06T15:07:08.000Z","size":24,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T18:49:14.040Z","etag":null,"topics":["golang","grpc","http2","load-balancer","microservices","proxy","reverse-proxy","rpc","traefik","traefik-v2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LdDl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-28T18:36:09.000Z","updated_at":"2024-04-07T13:03:08.000Z","dependencies_parsed_at":"2023-05-18T14:00:31.368Z","dependency_job_id":null,"html_url":"https://github.com/LdDl/traefik-grpc-reverse-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ftraefik-grpc-reverse-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ftraefik-grpc-reverse-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ftraefik-grpc-reverse-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Ftraefik-grpc-reverse-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LdDl","download_url":"https://codeload.github.com/LdDl/traefik-grpc-reverse-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243676717,"owners_count":20329432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","grpc","http2","load-balancer","microservices","proxy","reverse-proxy","rpc","traefik","traefik-v2"],"created_at":"2024-11-21T00:05:36.312Z","updated_at":"2026-05-20T09:31:40.666Z","avatar_url":"https://github.com/LdDl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Just an example how to make reverse proxy for gRPC\n\n### Backstory\n  Some time ago I had a task to do reverse proxy for multiple gRPC services.\n\n  I've already known how to do common HTTP/HTTPS/WS/WSS stuff with both [Traefik](https://traefik.io/) and [Ngnix](https://nginx.org), but I had not have familiar with HTTP2 (which is gRPC based on) reverse proxy.\n  I've start digging into and now I provide some workaround below.\n\n\n### Requirements:\n\n* Installed Traefik - https://doc.traefik.io/traefik/getting-started/install-traefik/\n  \n  In my case I've used binary distribution for linux_amd64.tar.gz with [v2.6.2 tag](https://github.com/traefik/traefik/releases/tag/v2.6.2). Your mileage may vary.\n  \n  Why no Nginx? There is no objective reason... I've just tried to do it with Traefik and it worked\n\n  \n* Prepared configuration file.\n\n  I prefer to have *.toml format. I'll describe some of its contents later.\n\n* Clone this repo and navigate to main directory\n  ```shell\n  git clone https://github.com/LdDl/traefik-grpc-reverse-proxy.git\n  cd traefik-grpc-reverse-proxy\n  ```\n\n### Run\n\n* Run first service\n   \n  ```shell\n  go run service_one/cmd/main.go\n  ```\n\n  \u003cdetails\u003e\n  \u003csummary\u003eIf you want to rebuild *.pb.go from *.proto file(-s) click to expand [Optional]\u003c/summary\u003e\n\n  * Be sure that you have protoc with Go compatibility\n    \n  * Run protoc\n    ```shell\n    protoc -I service_one/rpc/proto service_one/rpc/proto/*.proto --go_out=plugins=grpc:service_one/rpc/proto/\n    ```\n\n  \u003c/details\u003e\n\n\n* Run second service\n   \n  ```shell\n  go run service_one/cmd/main.go\n  ```\n\n  \u003cdetails\u003e\n  \u003csummary\u003eIf you want to rebuild *.pb.go from *.proto file(-s) click to expand [Optional]\u003c/summary\u003e\n\n  * Be sure that you have protoc with Go compatibility\n    \n  * Run protoc\n    ```shell\n    protoc -I service_two/rpc/proto service_two/rpc/proto/*.proto --go_out=plugins=grpc:service_two/rpc/proto/\n    ```\n\n  \u003c/details\u003e\n\n* Start Traefik\n  \n  ```shell\n  ./traefik --configFile=./grpc_proxy_example.toml\n  ```\n\n  Main challenge to prepare reverse proxy is to prepare correct rules for forwaring.\n  ```bash\n  ...\n  rule = \"PathPrefix(`/service_one.Service`)\"\n  # Where 'service_one' is package name of first service protobuf and 'Service' is service name\n  ...\n  rule = \"PathPrefix(`/service_two.Service`)\"\n  # Where 'service_two' is package name of second service protobuf and 'Service' is service name\n  ...\n  ```\n  Don't forget that load balancer URL has to start with \"h2c://\" since it's HTTP2\n\n* Start test client\n  \n  Note: make sure that *.proto files in client folder match same files in services folders (and rebuild it if necessary)\n  \u003cdetails\u003e\n  \u003csummary\u003eIf you want to rebuild client protobuffs [Optional]\u003c/summary\u003e\n\n  ```shell\n  protoc -I client/proto_one client/proto_one/*.proto --go_out=plugins=grpc:client/proto_one/\n  protoc -I client/proto_two client/proto_two/*.proto --go_out=plugins=grpc:client/proto_two/\n  ```\n\n  \u003c/details\u003e\n\n  Run:\n  ```shell\n  go run client/cmd/main.go\n  ```\n  If everything goes fine then you'll see:\n  ```shell\n  Response from service #1 is: code:200  text:\"Message from service #1\"\n  Response from service #2 is: code:200  text:\"Message from service #2\"\n  Response from service #1 (reverse proxy) is: code:200  text:\"Message from service #1\"\n  Response from service #2 (reverse proxy) is: code:200  text:\"Message from service #2\n  ```\n\n* That's all. Now you know how to do gRPC reverse proxy via Traefik\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Ftraefik-grpc-reverse-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flddl%2Ftraefik-grpc-reverse-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Ftraefik-grpc-reverse-proxy/lists"}