技术解析

nginx 转发 gprc 请求, UNAVAILABLE: HTTP status code 502
0
2021-05-19 17:36:22
idczone

client 报错:
UNAVAILABLE: HTTP status code 502

nginx 日志:
upstream sent too large http2 frame: 1377025 while reading response header from upstream, client: 127.0.0.1, server: hsltest.org1.peer0, request: "POST /protos.Events/Chat HTTP/2.0"

nginx 需要配置那些信息啊

nginx 配置如下

http {
    include       mime.types;

    default_type  application/octet-stream;
    log_format main '$remote_addr - $upstream_addr - [$time_local] "$request" $status    	 $body_bytes_sent "$http_referer" "$http_user_agent" "-" "$host"';
    access_log    logs/http.access.log;
    sendfile      on;
    tcp_nopush    on;
    tcp_nodelay   on;
    
	keepalive_timeout 240;
	grpc_buffer_size 8m;
	http2_max_field_size  2m;
	http2_max_header_size 2m;
大带宽服务器	
	proxy_buffer_size   2m;
	proxy_buffers   4 2m;
	proxy_busy_buffers_size   2m;
	http2_recv_buffer_size 2m;
	http2_chunk_size  2m;
	
    server_names_hash_bucket_size 128;
   
    ssl on;
    ssl_certificate ssh/org1.peer0.tls.cer;
	ssl_certificate_key ssh/org1.peer0.tls.key;
	ssl_client_certificate ssh/org1.tlsca.cer;
	ssl_verify_client on;

	server {
    			listen 1051 ssl http2; 
				server_name hsltest.org1.peer0;	
    			location / {   		
    				grpc_pass grpc://192.168.235.128:1051;
    			}
    		}
						
}

nginx 1.13.10 版本开始支持 grpc,老版本可以把 grpc 当做 tcp server 来配置

版本是 1.14.2

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服