【问题标题】:Undertow: How to control choosing host depends on request body content?Undertow:如何控制选择主机取决于请求正文内容?
【发布时间】:2019-03-07 18:33:24
【问题描述】:

我尝试像这样实现自己的代理:

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:8080localhost:7777

是否可以在 Undertow 代理中使用?

附:如果无法进行undertow,我准备切换到另一个代理

【问题讨论】:

    标签: java load-balancing reverse-proxy undertow


    【解决方案1】:

    我正在使用 Jetty org.eclipse.jetty.proxy.ProxyServlet 管理后端的动态列表。

    您可以选择目标后端覆盖: org.eclipse.jetty.proxy.AbstractProxyServlet.rewriteTarget(HttpServletRequest)

    (我也只想使用 Undertow)

    【讨论】:

      猜你喜欢
      • 2011-11-03
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多