Standard gRPC/Protobuf servicers are by default attached to specific paths 
like "/ServiceName/MethodName" not under "/grpc" so you need to proxy those 
specific paths in nginx config

--
Mehrdad Afshari
CEO, Signeen.com <https://www.signeen.com>

On Wednesday, November 27, 2024 at 7:00:42 PM UTC-8 Bairon Paz wrote:

> Hi yall, I am trying to set up a proxy for my gRPC server.
>
> I am using NGINX as a reverse proxy locally ran using docker-compose. My 
> idea is to run the following:
>
> api.domain.com/api to my regular Express server and api.domain.com/grpc 
> my regular grpc server.
>
> I have the following on my nginx.conf
> events {
>   worker_connections 1024;
> }
>
> http {
>
>     map $http_upgrade $connection_upgrade {
>         default upgrade;
>         '' close;
>     }
>
>     # All other servers, eg: admin dashboard, client website etc
>
>
>     server {
>         listen 80;
>         http2 on;
>         server_name http://api.domain.com;
>
>         location /api {
>             proxy_pass http://host.docker.internal:5001;
>             proxy_set_header Host $host;
>             proxy_set_header X-Real-IP $remote_addr;
>             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>             proxy_set_header X-Forwarded-Proto $scheme;
>
>             # WebSocket support
>             proxy_http_version 1.1;
>             proxy_set_header Upgrade $http_upgrade;
>             proxy_set_header Connection $connection_upgrade;
>         }
>
>         location /grpc {
>             grpc_pass grpc://host.docker.internal:50051;
>         }
>     }
>
> }
>
>
> I am using nginx:alpine.
>
> Calling grpc://host.docker.internal:50051 on postman works fine but trying 
> to call http:api.dev-local.com/grpc wont work.
>
> curl -I on the domain shows HTTP/1.1 regardless of setting : http2 on;.
> Now I also plan to put this in a EC2 server for production, I use nginx 
> there but I think its gonna be easier to set it up using ALB.
>
> Any ideas on why this is not working?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/grpc-io/a5005961-0891-443b-8aee-1093b8f21819n%40googlegroups.com.

Reply via email to