1、版本
1.18.0
2、编译安装:
./configure --prefix=/usr/local/nginx/ --with-http_ssl_module --with-http_v2_module
注释:
因为grpc是基于http2 所以安装的时候要加上这个模块
--with-http_ssl_module --with-http_v2_module
make
make install
3、启动
/usr/local/nginx/sbin/nginx
4、在8400端口开启grpc服务
5、负载配置
upstream grpc_load {
server 127.0.0.1:8499;
server 127.0.0.1:8498;
}
server {
listen 8500 http2;
server_name localhost;
access_log logs/host.access.log main;
location / {
grpc_pass grpc://grpc_load;
}
}
6、通过自己编写的grpc客户端调用(8500端口)
得到grpc调用结果,同时查看nginx访问日志,可以看到
127.0.0.1 - - [02/Jun/2020:16:54:12 +0800] "POST /api/get_method HTTP/2.0" 200 777 "-" "grpc-python/1.21.1 grpc-c/7.0.0 (manylinux; chttp2; gandalf)" "-"