2

我配置我的 nginx:

user root;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

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

server {
        listen 80 ssl http2;

        ssl_certificate     MY_PATH/ssl_truststore.pem;
        ssl_certificate_key MY_PATH/ssl_keystore.pem;
        ssl_password_file /root/passwd;

        server_name my-server-name;

        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://my-server-name:1234;
        }
    }
}

我想为 SSL grpc 服务器配置安全的 nginx L7 负载平衡。在非安全 grpc 服务器上,非安全 nginx 运行良好。但是在安全时我得到了一个错误:

2018/07/20 07:00:42 [error] 6988#6988:
*1 upstream prematurely closed connection while reading response header from upstream,
client: some-ip, server:my-server-name, 
request: "POST XXXX HTTP/2.0", 
upstream: "grpc://my-server-name:1234", host: "my-server-name"

我试图找到解决此问题的方法,但没有适合我的方法。

4

1 回答 1

0

需要改变

grpc_pass grpcs://my-server-name:1234;

找到了解决方案。

于 2018-07-20T15:03:02.807 回答