The original post: /r/nginx by /u/Revolutionary-Star71 on 2024-11-28 01:46:57.
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 ;
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?