反向代理 Java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25485979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 08:05:38  来源:igfitidea点击:

Reverse Proxy Java

javaproxyreverse-proxyembedded-jettyembedded-tomcat-7

提问by F.O.O

I am working with a Java web application and I would like to have a reverse proxy masking some of my internal endpoints.

我正在使用 Java Web 应用程序,并且我想要一个反向代理来屏蔽我的一些内部端点。

Requirements
1. The reverse proxy maps need to be modifiable at runtime e.g if we move some components to another server we should be able to modify the mapping such that new requests are routed to this endpoint.
2. This must be embeddable to a standard servlet container like Jetty.

要求
1. 反向代理映射需要在运行时可修改,例如,如果我们将某些组件移动到另一台服务器,我们应该能够修改映射,以便将新请求路由到此端点。
2. 这必须可以嵌入到像 Jetty 这样的标准 servlet 容器中。

Most of the Java Reverse Proxies out there such as J2EP require mapping information available prior to starting the application.

大多数 Java 反向代理(例如 J2EP)都需要在启动应用程序之前提供可用的映射信息。

回答by Andreas

As far as I can see, http://www.membrane-soa.org/service-proxy/supports all your requirement:

据我所知,http: //www.membrane-soa.org/service-proxy/支持您的所有要求:

Membrane has a WebUI where you can add and remove proxy connections at runtime, e.g. forward incoming request on port 80 for a virtual host to a target host:port

Membrane 有一个 WebUI,您可以在其中添加和删除运行时的代理连接,例如将虚拟主机在端口 80 上的传入请求转发到目标主机:端口

Membrane can be run as standalone application or deployed in an application server.

Membrane 可以作为独立的应用程序运行,也可以部署在应用程序服务器中。

Membrane is an Open Source project under the ASF 2.0 License

Membrane 是 ASF 2.0 许可下的开源项目

回答by Andrejs

Undertowprovides an embeddable reverse proxy server that can be changed programatically at runtime.

Undertow提供了一个可嵌入的反向代理服务器,可以在运行时以编程方式进行更改。

If you want to operate at a higher level via an API then there is Backflow. It supports adding/removing proxy backends using REST calls.

如果您想通过 API 在更高级别进行操作,则可以使用Backflow。它支持使用 REST 调用添加/删除代理后端。