如何在spring-cloud-gateway中为netty客户设置代理?

时间:2019-07-03 08:03:41

标签: proxy netty spring-webflux spring-cloud-gateway reactor-netty

(这样,从spring-cloud-gateway到下游服务的所有请求都将通过代理)

我指的是https://github.com/spring-cloud/spring-cloud-gateway/issues/176

按照

为netty客户配置代理
spring:
  cloud:
    gateway:
      httpclient:
        connectTimeout: 5000
        proxy:
          host: test.proxy.local
          port: 8080

当呼叫spring-cloud-gateway时,希望该呼叫通过代理进行并进入配置的实际下游URL中。

当代理尝试连接时,出现以下错误

 i.n.handler.proxy.ProxyConnectException: http, none, test.proxy.local/172.18.199.200:8080 => api.cicd.ps.money:80, status: 403 Proxy denies fulfilling the request
    at io.netty.handler.proxy.HttpProxyHandler.handleResponse(HttpProxyHandler.java:188)
    at io.netty.handler.proxy.ProxyHandler.channelRead(ProxyHandler.java:260)
    at i.n.c.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at i.n.c.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at i.n.c.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at i.n.c.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)
    at i.n.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
    at i.n.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
    at i.n.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)
    at i.n.c.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at i.n.c.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at i.n.c.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at i.n.c.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
    at i.n.c.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at i.n.c.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
    at i.n.c.n.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:648)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
    at i.n.u.c.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
    at java.lang.Thread.run(Thread.java:748)

0 个答案:

没有答案