Nginx配置gprc:
安装最新版nginx(参考官方文档nginx.org) 配置grpc的负载均衡参考简书的“平仄_pingze”的博客(https://www.jianshu.com/p/59b00b6401b0)
2、echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
3、echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
4、curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
5、sudo apt-key fingerprint ABF5BD827BD9BF62
6、sudo apt update
7、sudo apt install nginx
conf文件位置/etc/nginx
upstream grpctest {
server 127.0.0.1:50051 weight=5;
server 127.0.0.1:50052 weight=5;
}
server {
listen 5005 http2;
access_log /var/webos/logs/nginx/grpctest.log main;
location / {
grpc_pass grpc://grpctest;
}
}
ps:nginx运行失败可以使用‘nginx -c 刚才改的配置文件名’来运行。
遇到报错的问题可以加sudo尝试一下。
nginx -s (reload stop quit)
nginx -c 指定配置文件
nginx -t 查看是否安装正确
nginx -v 查看版本号
start nginx 启动nginx