Project: Easegress (Orchestration & Management / API Gateway)
File: 2.7.gRPC.md

- The `GRPCServer` in Easegress provides robust functionality tailored to gRPC protocol interactions. With its IP filtering feature, traffic can be selectively allowed or blocked, ensuring that only desired clients can communicate with the services. Additionally, the server's routing rules offer flexible methods to determine how each incoming request is processed and forwarded, based on host, method, headers, and other criteria. ``` yaml name: server-grpc kind: GRPCServer port: 8080 maxConnections: 10240 ipFilter: blockIPs: [] allowIPs: [] blockByDefault: false rules: host: <your-host> hostRegexp: <your-host-regexp> methods: method: /Sale/AddProduct # Exact method match backend: sale-pipeline methodPrefix: /IT # Matches method with the given prefix backend: it-pipeline headers: # Matches by header key: x-geo-country values: ["CN", "EU", "US"] key: user-agent values: ["SaleClient/1.0.0"] matchAllHeader: false backend: header-pipeline methodRegexp: .* # Match by regexp backend: other-pipeline methods: ... ``` For an in-depth exploration of the GRPCServer settings, please refer to the . A gRPC request with method `/Sale/AddProduct` will be routed to the `sale-pipeline`. Any request with a method starting with `/IT` (e.g., `/IT/UpdateSoftware`) will be directed to the `it-pipeline`. If a client sends a request with headers `x-geo-country` set to `CN` and `user-agent` set to `SaleClient/1.0.0`, it will be handled by the `header-pipeline`. All other requests (due to the wildcard `methodRegexp`) will be sent to the `other-pipeline`. The `GRPCProxy` filter in Easegress serves as a specialized proxy designed for gRPC backend services. This filter facilitates both unary and streaming RPCs, ensuring seamless communication in a gRPC ecosystem. Here's a basic configuration of the `GRPCProxy` filter that directs incoming gRPC connections to two backend servers, `192.168.1.1:80` and `192.168.1.2:80`: ```yaml name: demo-pipeline kind: Pipeline flow: proxy filters: kind: GRPCProxy name: proxy pools: loadBalance: policy: roundRobin servers: url: http://192.168.1.1:80 url: http://192.168.1.2:80 ``` Same as the `Proxy` filter: a `filter` can be configured on a pool. the servers of a pool can be configured dynamically via service discovery. when there are multiple servers in a pool, the pool can do a load balance between them. Because gRPC does not support the http `Connect` method, it does not support tunneling mode, we provide a new `policy.forward` to achieve a similar effect. Note that each gRPC client establishes a connection with Easegress. However, Easegress may utilize a single connection when forwarding requests from various clients to a gRPC server, due to its use of HTTP2. This action could potentially disrupt some client or server applications. For instance, if the client applications are structured to directly connect to the server, and both the client and server have the ability to request a connection closure, then problems may arise once Easegress is installed between them. If the server wants to close the connection of one client, it closes the shared connection with Easegress, thus affecting other clients. For more details about filter.