问题
I am working with a Java web application and I would like to have a reverse proxy masking some of my internal endpoints.
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.
Most of the Java Reverse Proxies out there such as J2EP require mapping information available prior to starting the application.
回答1:
As far as I can see, http://www.membrane-soa.org/service-proxy/ supports all your requirement:
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 can be run as standalone application or deployed in an application server.
Membrane is an Open Source project under the ASF 2.0 License
回答2:
Undertow provides an embeddable reverse proxy server that can be changed programatically at runtime.
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.
来源:https://stackoverflow.com/questions/25485979/reverse-proxy-java