<div><p>Hello!</p><p style="color:rgb( 64 , 64 , 64 );font-family:'inter' , 'system-ui' , '-apple-system' , 'blinkmacsystemfont' , 'segoe ui' , 'roboto' , 'noto sans' , 'ubuntu' , 'cantarell' , 'helvetica neue' , 'oxygen' , 'open sans' , sans-serif;font-size:16.002px;font-style:normal;font-weight:400;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">There is an urgent need to balance gRPC traffic using nginx. I set up a simple test environment with two gRPC services. One of the services is behind a proxy (nginx).</p><p style="color:rgb( 64 , 64 , 64 );font-family:'inter' , 'system-ui' , '-apple-system' , 'blinkmacsystemfont' , 'segoe ui' , 'roboto' , 'noto sans' , 'ubuntu' , 'cantarell' , 'helvetica neue' , 'oxygen' , 'open sans' , sans-serif;font-size:16.002px;font-style:normal;font-weight:400;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Here is the load balancer configuration:</p><div><em>upstream grpc_upstream {<!-- --></em></div><div><em>  server        192.168.100.30:8080 max_fails=1 fail_timeout=15s;</em></div><div><em>  server        192.168.100.11:30002 max_fails=1 fail_timeout=15s;</em></div><div><em>}</em></div><div> </div><div><em>server {<!-- --></em></div><div><em>       listen                                 80;</em></div><div><em>       http2                                  on;</em></div><div><em>       server_name                            nginx.home.local;</em></div><div><em>       gzip                                   off;</em></div><div><em>       charset                                utf-8;</em></div><div><em>       large_client_header_buffers            8 256k;</em></div><div> </div><div> </div><div><em>       location / {<!-- --></em></div><div><em>         grpc_buffer_size       256k;</em></div><div><em>         grpc_next_upstream     error timeout invalid_header http_504 http_503 http_502 http_500;</em></div><div><em>         grpc_set_header        X-Real-IP $remote_addr;</em></div><div><em>         grpc_set_header        X-Forwarded-For $remote_addr;</em></div><div><em>         grpc_set_header        X-Forwarded-Host $host;</em></div><div><em>         grpc_pass_header       Set-Cookie;</em></div><div><em>         grpc_pass              grpc://grpc_upstream;</em></div><div><em>       }</em></div><div><em>}</em></div><pre style="color:rgb( 255 , 255 , 255 );font-size:12.573px;font-style:normal;font-weight:400;margin-bottom:0px !important;margin-left:0px !important;margin-right:0px !important;margin-top:0px !important;overflow:auto;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:pre-wrap;word-break:break-all;word-spacing:0px">
 </pre><p style="color:rgb( 64 , 64 , 64 );font-family:'inter' , 'system-ui' , '-apple-system' , 'blinkmacsystemfont' , 'segoe ui' , 'roboto' , 'noto sans' , 'ubuntu' , 'cantarell' , 'helvetica neue' , 'oxygen' , 'open sans' , sans-serif;font-size:16.002px;font-style:normal;font-weight:400;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">When the gRPC service behind the proxy server is turned off, our nginx load balancer receives 502 errors but does not remove the server from the upstream. Half of the requests fail.</p><p style="color:rgb( 64 , 64 , 64 );font-family:'inter' , 'system-ui' , '-apple-system' , 'blinkmacsystemfont' , 'segoe ui' , 'roboto' , 'noto sans' , 'ubuntu' , 'cantarell' , 'helvetica neue' , 'oxygen' , 'open sans' , sans-serif;font-size:16.002px;font-style:normal;font-weight:400;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Here is the output from <code style="border-radius:4px;font-size:0.875em;padding:0.15rem 0.3rem 0.15rem 0.3rem">tail -f /var/log/nginx/access.log</code>:</p><div><em>192.168.100.11 - - [01/Feb/2025:12:02:06 +0300] "POST /helloworld.Greeter/SayHello HTTP/2.0" 502 157 "-" "grpcurl/v1.9.1 grpc-go/1.61.0" "-"</em></div><div><em>192.168.100.11 - - [01/Feb/2025:12:02:07 +0300] "POST /helloworld.Greeter/SayHello HTTP/2.0" 200 15 "-" "grpcurl/v1.9.1 grpc-go/1.61.0" "-"</em></div><div><em>192.168.100.11 - - [01/Feb/2025:12:02:08 +0300] "POST /helloworld.Greeter/SayHello HTTP/2.0" 502 157 "-" "grpcurl/v1.9.1 grpc-go/1.61.0" "-"</em></div><div><em>192.168.100.11 - - [01/Feb/2025:12:02:09 +0300] "POST /helloworld.Greeter/SayHello HTTP/2.0" 200 15 "-" "grpcurl/v1.9.1 grpc-go/1.61.0" "-"</em></div><div><em>192.168.100.11 - - [01/Feb/2025:12:02:10 +0300] "POST /helloworld.Greeter/SayHello HTTP/2.0" 502 157 "-" "grpcurl/v1.9.1 grpc-go/1.61.0" "-"</em></div><div><em>192.168.100.11 - - [01/Feb/2025:12:02:11 +0300] "POST /helloworld.Greeter/SayHello HTTP/2.0" 200 15 "-" "grpcurl/v1.9.1 grpc-go/1.61.0" "-"</em><p style="color:rgb( 64 , 64 , 64 );font-family:'inter' , 'system-ui' , '-apple-system' , 'blinkmacsystemfont' , 'segoe ui' , 'roboto' , 'noto sans' , 'ubuntu' , 'cantarell' , 'helvetica neue' , 'oxygen' , 'open sans' , sans-serif;font-size:16.002px;font-style:normal;font-weight:400;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I found a similar case here: <a href="https://trac.nginx.org/nginx/ticket/2060" rel="noopener noreferrer" target="_blank" style="margin-left:-3px;margin-right:-3px;text-decoration:none">https://trac.nginx.org/nginx/ticket/2060</a>.</p><p>Could you please let me know if there are any plans to address this issue?</p></div></div>