I try to implement my own proxy like this:
LoadBalancingProxyClient loadBalancer = new LoadBalancingProxyClient()
.addHost(new URI("http://localhost:8080"))
.addHost(new URI("http://localhost:7777"))
.setConnectionsPerThread(20);
Undertow reverseProxy = Undertow.builder()
.addHttpListener(8081, "localhost")
.setIoThreads(1)
.setHandler(ProxyHandler.builder().setProxyClient(loadBalancer).setMaxRequestTime(30000).build())
.build();
reverseProxy.start();
I want to have control over choosing proxy server. Depends on request body I want to choose localhost:8080
or localhost:7777
Is it possible in Undertow proxy?
P.S. I am ready to switch to another proxy if it is impossible for undertow
I am using Jetty
org.eclipse.jetty.proxy.ProxyServlet
managing a dynamic list of backends.You can select the target backend overriding:
org.eclipse.jetty.proxy.AbstractProxyServlet.rewriteTarget(HttpServletRequest)
(I would like to use Undertow only too)