gRPC服务

gRPC服务

支持条件:

1、使用NGINX 1.13.10以上版本

2、需要编译$ auto/configure --with-http_ssl_module --with-http_v2_module模块
3、配置文件

在端口80上侦听未加密的gRPC流量,并在端口50051上将请求转发到服务器:

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';

server {
listen 80 http2;

access_log logs/access.log main;

location / {
# Replace localhost:50051 with the address and port of your gRPC server
# The 'grpc://' prefix is optional; unencrypted gRPC is the default
grpc_pass grpc://localhost:50051;
}
}
}

使用TLS加密发布gRPC服务

upstream grpcservers {
server 192.168.20.11:50051;
server 192.168.20.12:50051;
}

server {
listen 1443 ssl http2;

ssl_certificate ssl/certificate.pem;
ssl_certificate_key ssl/key.pem;

location /helloworld.Greeter {
grpc_pass grpc://grpcservers;
error_page 502 = /error502grpc;
}

location = /error502grpc {
internal;
default_type application/grpc;
add_header grpc-status 14;
add_header grpc-message "unavailable";
return 204;
}
}

 

posted @ 2019-05-04 21:58  Boks  阅读(592)  评论(0)    收藏  举报