Spring cloud spring云网关webflux ProxyExchange返回404

Spring cloud spring云网关webflux ProxyExchange返回404,spring-cloud,spring-cloud-gateway,Spring Cloud,Spring Cloud Gateway,我想用SpringCloudGateway创建一个简单的代理和聚合服务器。我正在使用dependencySpringCloudGatewayWebFlux和ProxyExchange来实现这一点。我在localhost中启动应用程序并从浏览器启动,但是,它返回404 not found 如果我使用springcloudgatewaymvc而不是springcloudgatewaywebflux,那么代理可以正常工作,我可以在本地主机上浏览stackoverflow。但我仍然想知道为什么sprin

我想用SpringCloudGateway创建一个简单的代理和聚合服务器。我正在使用dependency
SpringCloudGatewayWebFlux
和ProxyExchange来实现这一点。我在localhost中启动应用程序并从浏览器启动,但是,它返回404 not found

如果我使用
springcloudgatewaymvc
而不是
springcloudgatewaywebflux
,那么代理可以正常工作,我可以在本地主机上浏览stackoverflow。但我仍然想知道为什么
springcloudgatewaywebflux
不起作用

有人能帮我指出我遗漏了什么吗

控制器:

@RestController
public class RouteController {
    @RequestMapping(value="/**", method={ RequestMethod.GET, RequestMethod.POST })
    public Mono<ResponseEntity<byte[]>> proxy(ServerHttpRequest request, ServerHttpResponse response, ProxyExchange<byte[]> proxy) throws Exception {
        String path = proxy.path("/");
        if (request.getMethodValue().startsWith("GET")) {
            return proxy.uri("https://stackoverflow.com/" + path).get();
        } else {
            return proxy.uri("https://stackoverflow.com/" + path).post();
        }
    }
}
我尝试将以下内容添加到application.yml中,但不起作用

spring:
  cloud:
    gateway:
      httpclient:
        ssl:
          useInsecureTrustManager: true

在我的情况下,这是http头的问题。添加以下代码,那么一切都适合我

proxy.sensitive(HttpHeaders.HOST)

似乎ProxyExchange默认情况下会传递http请求头,在
WebClient
的情况下,没有默认的http头。

这些配置属性仅适用于独立网关,而不适用于这些模块。这些属性的前缀是
spring.cloud.gateway.proxy
。我猜
restemplate
默认情况下会忽略ssl错误,
WebClient
不会。您可以创建一个
ProxyExchangeArgumentResolver
bean,并适当地配置
WebClient
。参见@spencergib您的意思是我应该设置属性spring.cloud.gateway.proxy.ssl.UseSecureTrustManager=true吗?我试过了,但还是不起作用。那个财产不存在。要做你想做的事,你需要复制我链接到的代码。谢谢@Spencergib。我添加了一个
ProxyExchangeArgumentResolver
bean,但仍然不起作用。bean代码在这里()。我不确定我是否做错了什么,尤其是注释。这对我来说确实有效
proxy.sensitive(HttpHeaders.HOST)