参考:https://www.nginx.com/blog/nginx-1-13-10-grpc/
重点是标记红色的部分
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; } } }
比如下面这个:
这里配置用的是openresty,-V查看的时候并没有查看到grpc相关模块,就能支持了,可能是已经有人装了模块了吧,或者默认就能用?
访问:http://xxx.internalxxx.com:50051 生产配置案例: upstream xxx-internalxx50051 { server 10.0.0.49:50051 weight=10000 max_fails=3; server 10.0.0.193:50051 weight=10000 max_fails=3; server 10.0.0.41:50051 weight=10000 max_fails=3; keepalive 64; } server { listen 50051 http2; server_name xxx.internalxxx.com; location / { grpc_pass grpc://xxx-internalxx50051; #proxy_pass http://xxx-internalxx50051; #proxy_redirect off; #proxy_set_header Host $host; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_http_version 1.1; } access_log /data/logs/nginx/xxx-internalxx2_access.log main; error_log /data/logs/nginx/xxx-internalxx2_error.log; }
标签:log,grpc,xxx,代理,server,nginx,50051,proxy
From: https://www.cnblogs.com/machangwei-8/p/17901489.html