如何为 Node Express 和 Grpc 微服务配置 nginx?
我有这个问题需要解决:
我应该使用 nginx 进行微服务之间的通信,但我不知道从哪里开始。 我使用 Node Express 进行客户端(例如 React ap)和 Grpc 中的两个微服务之间的通信。
我无法与我的 Express 节点和 grpc 进行通信。 我该如何编写我的文件配置 nginx ?
我现在已经写了:
upstream api {
server api:80;
}
upstream exchange{
server exchange:9001;
}
upstream users{
server users:9002
}
server {
listen 8080;
location / {
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_pass api;
}
location /excahgne{
grpc_pass excahgne
}
location /users{
grpc_pass users
}
}
我应该如何将流量从 epress endpint 路由到 grpc 客户端?
es endpoit
app.get("/exchange",(req,res)=>{
clientGrpc.exchange(call,callback=>{
operations..........
res.send(data)
}
}
我总是收到“未建立连接”。
我可以进入 enpoint,但不能进入 grpc 微服务。
请帮助我
I have this problem to solving:
I should use nginx for comunications between my microservices, but I don't know where I can start.
I use node express for comunications between client (es. react ap) and two microservice in Grpc.
I'm not able for comunicate with my express node and grpc.
How could I write my file config nginx ?
I have write this for now :
upstream api {
server api:80;
}
upstream exchange{
server exchange:9001;
}
upstream users{
server users:9002
}
server {
listen 8080;
location / {
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_pass api;
}
location /excahgne{
grpc_pass excahgne
}
location /users{
grpc_pass users
}
}
How should I route traffic from the epress endpint to the grpc client?
es endpoit
app.get("/exchange",(req,res)=>{
clientGrpc.exchange(call,callback=>{
operations..........
res.send(data)
}
}
I RECEIVE ALWAYS "No connection established".
I can get into the enpoint, but not the grpc microservice.
Help me please
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论