Home > Software engineering >  How to use gRPC with cloudflare nginx fabio?
How to use gRPC with cloudflare nginx fabio?

Time:12-20

I have a gRPC Java app and I configured Fabio to balance the load (I will be running 2 instances of app) and CloudFlare for proxy.

What I have done so far:

Nginx reverse proxy setup

server {
    listen [::]:443 ssl http2 ipv6only=on;
        listen 443 ssl http2;

    server_name grpc.example.com;

    location /{
        grpc_pass grpc://127.0.0.1:9999;
    }
        ssl_certificate /etc/letsencrypt/live/grpc.example.com/fullchain.pem; 
        ssl_certificate_key /etc/letsencrypt/live/grpc.example.com/privkey.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf;
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

}

CloudFlare setup:
Grpc is enabled

Subdomain configuration for domain (IP is random in picture)
subdomain

Fabio setup
gRPC app runs in a Docker container

running app

When I connect to this server using gRPC client, I get nginx error "502 Bad Gateway".

I can see from access.log that request actually reaches with http/2.0 but I am confused and I don't know where to look for problem.

Also error.log shows this for requests:

2022/12/12 23:38:45 [error] 506072#506072: *1020 upstream sent too large http2 frame: 4740180 while reading response header from upstream, client: 61.142.22.151, server: grpc.example.com, request: "POST /Syncer/doUpdate HTTP/2.0", upstream: "grpc://127.0.0.1:9999", host: "grpc.example.com:443"

CodePudding user response:

Adding GRPC listener with port solved the issue

proxy.addr = :8888;proto=grpc
  • Related