GRPC reverse proxy using same port for multiple grpc host/ports

Maxim Dounin mdounin at mdounin.ru
Wed May 29 16:18:24 UTC 2019


Hello!

On Tue, May 28, 2019 at 10:41:15PM -0400, isuru wrote:

> Hi All,
> I am trying to reverseproxy http2 base grpc using nginx.I attempted with
> nginx port 9092 to proxy to singl e grpc host  port using a conf file inside
> conf.d.
> 
>  map $http_upgrade $connection_upgrade {
>     default upgrade;
>     ''        close;
>   }
> 
>   upstream sendssmgrpcservers {
>     # The docker endpoint of your grpc servers, you can have multiple here
>     server 10.2.4.25:6568;
>     #server 10.2.4.200:6566;
>   }
> 
> #upstream sendSSMgrpcservers {
> #server 10.2.4.25:6568;
> #}
> 
>   server {
>     listen  9092  http2;
>     location / {
> 
>       # The 'grpc://' prefix is optional; unencrypted gRPC is the default
>       grpc_pass grpc://sendssmgrpcservers;
> #grpc_pass grpc://10.2.4.226:6566;  
>                                                              
> }}
> 
> When I add another conf file for the same port with a  different domain name
> in conf and to a different grpc host/port as upstream  It does not  forward
> to right grpc host port.
> 
> Does http2 grpc reverseproxy not support multiple grpc host/port forward on
> same port?If yes how to  configure that

nginx itself can handle name-based virtual servers for gRPC much 
like for any other HTTP requests, just configuring appropriate 
names via the server_name directive should be enough.  But this 
may not work if your gRPC client does not provide appropriate Host 
and/or :authority headers in requests.

To find out what exactly happens with requests and if appropriate 
headers are present, consider using debugging log.  See here for 
details:

http://nginx.org/en/docs/debugging_log.html

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list