如何在安全Nginx上修复“从上游读取响应标头时上游过早关闭的连接”

时间:2018-07-20 14:28:15

标签: python nginx load-balancing grpc grpc-python

我配置了我的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"

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

1 个答案:

答案 0 :(得分:0)

需要改变

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

找到解决方法。