问题描述
我尝试像这样实现自己的代理:
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();
我想控制选择代理服务器.取决于我要选择localhost:8080
或localhost:7777
I want to have control over choosing proxy server. Depends on request body I want to choose localhost:8080
or localhost:7777
在Undertow代理中可以吗?
Is it possible in Undertow proxy?
P.S.如果无法进行底线准备,我准备切换到另一个代理
P.S. I am ready to switch to another proxy if it is impossible for undertow
推荐答案
我正在使用Jetty org.eclipse.jetty.proxy.ProxyServlet
管理后端的动态列表.
I am using Jetty org.eclipse.jetty.proxy.ProxyServlet
managing a dynamic list of backends.
您可以选择目标后端覆盖:org.eclipse.jetty.proxy.AbstractProxyServlet.rewriteTarget(HttpServletRequest)
You can select the target backend overriding:org.eclipse.jetty.proxy.AbstractProxyServlet.rewriteTarget(HttpServletRequest)
(我也只想使用Undertow)
(I would like to use Undertow only too)
这篇关于Undertow:如何控制选择主机取决于请求主体的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!