How to enable nginx reverse proxy to work with gRPC in .Net core?

Below is the solution that works:

location /CartCheckoutService/ValidateCartCheckout {
                grpc_pass grpc://api;
            }

The only configuration for nginx that works when using grpc is using grpc_pass only. It's not similar to proxy pass and the other configuration is not required (i.e. passing the headers/protocol/etc from the request). I am finally able to get this to work without having to do upstream SSL and just use the proxy like I meant to - terminate SSL at the proxy.


Nginx proxy_pass does not support http/2. Since you're forwarding a gRPC connection, and gRPC requires http/2 the connection fails when it is sent via http/1 to the upstream.

Q: Will you support HTTP/2 on the upstream side as well, or only support HTTP/2 on the client side?

A: At the moment, we only support HTTP/2 on the client side. You can’t configure HTTP/2 with proxy_pass.

https://www.nginx.com/blog/http2-module-nginx/#QandA

As you have found, you need to use grpc_pass to forward the connection to the upstream gRPC server.

Tags:

Docker

Nginx

C#