最开始使用proxy_pass去代理了grpc服务,结果请求时候报错提示:

rpc error: code = Unavailable desc = connection error: desc = "error reading server preface: http2: frame too large"

后来才知道代理grpc服务需要使用grpc_pass,记录一下配置文件参

server {
    listen 17000 http2; 
    server_name www.grpc.com; 
    set $ipWhiteAllow off; 
    location / {
        grpc_pass grpc://127.0.0.1:9000;
        error_page 502 = /error502grpc;
    }
 
    location = /error502grpc {
        internal;
        default_type application/grpc;
        add_header grpc-status 14;
        add_header grpc-message "unavailable";
        return 204;
    }
}

监听17000端口,反向代理127.0.0.1:9000的GRPC服务

12-04 19:36