API网关与反向代理 [英] API gateway vs. reverse proxy

查看:138
本文介绍了API网关与反向代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了处理微服务架构,通常将其与反向代理(例如nginx或apache httpd)一起使用,并且用于实现跨领域的关注

In order to deal with the microservice architecture, it's often used alongside a Reverse Proxy (such as nginx or apache httpd) and for cross cutting concerns implementation API gateway pattern is used. Sometimes Reverse proxy does the work of API gateway.

很高兴看到这两种方法之间存在明显差异.API网关使用的潜在好处似乎是调用多个微服务并汇总结果.所有其他职责 API网关可以使用反向代理来实现.如:

It will be good to see clear differences between these two approaches. It looks like the potential benefit of API gateway usage is invoking multiple microservices and aggregating the results. All other responsibilities of API gateway can be implemented using Reverse Proxy. Such as:

  • 身份验证(可以使用nginx LUA脚本完成);
  • 运输安全.它本身就是反向代理任务;
  • 负载均衡
  • ...

因此,有几个问题:

  1. 同时使用API​​网关和反向代理是否有意义(例如,请求-> API网关->反向代理(nginx)->具体的微服务)?在什么情况下?
  2. 使用API​​网关可以实现的其他区别还有反向代理不能实现的其他区别,反之亦然吗?

推荐答案

如果您意识到它们不是互斥的,则更容易考虑它们.将API网关视为一种特定类型的反向代理实现.

It is easier to think about them if you realize they aren't mutually exclusive. Think of an API gateway as a specific type reverse proxy implementation.

关于您的问题,经常将两者结合使用,将API网关视为位于反向代理后面的应用程序层,以进行负载平衡和运行状况检查.一个例子就是类似WAF的三明治体系结构,其中Web应用程序防火墙/API网关被反向代理层夹持,其中一个用于WAF本身,另一个用于与之通信的单个微服务.

In regards to your questions, it is not uncommon to see the both used in conjunction where the API gateway is treated as an application tier that sits behind a reverse proxy for load balancing and health checking. An example would be something like a WAF sandwich architecture in that your Web Application Firewall/API Gateway is sandwiched by reverse proxy tiers, one for the WAF itself and the other for the individual microservices it talks to.

关于差异,它们非常相似.这只是术语.当您进行基本的反向代理设置并开始使用更多功能(例如身份验证,速率限制,动态配置更新和服务发现)时,人们更有可能调用该API网关.

Regarding the differences, they are very similar. It's just nomenclature. As you take a basic reverse proxy setup and start bolting on more pieces like authentication, rate limiting, dynamic config updates, and service discovery, people are more likely to call that an API gateway.

这篇关于API网关与反向代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆