nginx grpc 试用

1. 编译

wget https://nginx.org/download/nginx-1.13.10.tar.gz
tar xvf nginx-1.13.10.tar.gz
cd nginx-1.13.10
./configure --with-http_ssl_module --with-http_v2_module

备注:需要安装pcre  openssl 
centos 操作为: yum install -y pcre-devel openssl-devel
2. 简单配置
   upstream  grpc9001 {
       server 127.0.0.1:9001 weight=20 max_fails=2 fail_timeout=30s;
    }
    upstream  grpc9000 {
       server 127.0.0.1:9000 weight=20 max_fails=2 fail_timeout=30s;
    }
    server {
        listen       80 http2;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
            grpc_pass grpc://grpc9001;
        }
        location /userserviceapp.UserServiceApp{
          grpc_pass grpc://grpc9001;
        }
        location /echoservice.EchoService{
          grpc_pass grpc://grpc9000;
        }    
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
3. 几个问题
目前在使用  grpc-gateway中间件的时候存在内容content-type 的问题,具体的原因还需要进排查源码
对于grpc 的负载均衡以规则路由目前测试是没有问题的
4. 参考文档
https://www.nginx.com/blog/nginx-1-13-10-grpc/
https://mp.weixin.qq.com/s/kiMAMrPx_6lKYJlFwDK6rA
https://nginx.org/en/docs/http/ngx_http_grpc_module.html

posted on   荣锋亮  阅读(630)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2015-05-09 nodejs 任务调度使用
2014-05-09 SQL Server MERGE
2014-05-09 ORA-01791: not a SELECTed expression
2014-05-09 Oracle instr函数

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示