'How to set up a GCP LoadBalancer for mixed HTTP1.1,HTTP2.0 and gRPC traffic backends

GCP https load balancer classic

1: https://i.stack.imgur.com/Eyw1w.png**strong text**

I configured HTTPS load balancer with 2 VMs, 1 VM will work with http1.1 and another VM is created for 2 backends, one backend is for http2, and another backend with gRPC. The problem is that even though I configured http2 and grpc named ports for the 2nd VM instance group. I'm getting http1.1 requests only but not http2.0 and also gRPC health checks are failing while checking on another application(not in load balancer health checks). Below are my Nginx configs for http2 & grpc backends.

server {
  listen 80;
  server_name pqsaquilagcp.gcptest.anqlave.net;

  client_max_body_size 50m;
  proxy_connect_timeout                   600s;
  proxy_send_timeout                      600s;
  proxy_read_timeout                      600s;

  location / {
      proxy_pass http://127.0.0.1:8080;
  }
}

server {
  listen 80;
  listen 443 ssl http2;
  
  server_tokens off;
  server_name pqsaquilagcp.gcptest.anqlave.net;

  client_max_body_size          50m;
  proxy_connect_timeout         600s;
  proxy_send_timeout            600s;
  proxy_read_timeout            600s;

  location / {
      proxy_pass http://127.0.0.1:8080;
  }
  
  
}


server {
  listen 81 http2;
   
  server_tokens off;
  server_name grpc.pqsaquilagcp.gcptest.anqlave.net;

  client_max_body_size 600m;
  client_body_timeout 600s;
  grpc_read_timeout 600s;
  grpc_send_timeout 600s;
  grpc_connect_timeout 600s;

  location / {
     proxy_buffer_size          512k;
     proxy_buffers              4 256k;
     proxy_busy_buffers_size    512k;
     grpc_pass grpc://127.0.0.1:8080;
  }
  
}
[![enter image description here][1]][1]


Solution 1:[1]

From your screenshot, I only see backends configured to use port 80. Your Nginx server does not have TLS encryption enabled on port 80.

If you use HTTP/2, you must use TLS. HTTP/2 without encryption is not supported. link

To use gRPC with your Google Cloud applications, you must proxy requests end-to-end over HTTP/2.

Those concepts are discussed here:

External HTTP(S) Load Balancing overview

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Hanley