Spring cloud 为什么不是';当我设置前缀XPath和URI时,我的Spring云网关路由是否工作

Spring cloud 为什么不是';当我设置前缀XPath和URI时,我的Spring云网关路由是否工作,spring-cloud,spring-cloud-gateway,Spring Cloud,Spring Cloud Gateway,我有一个SpringCloudGateway,它位于其他微服务的前面。网关还用作身份验证层。我的网关位于localhost:9000,我希望将流量定向到localhost:8050上具有谓词路径(/api/scd/secure/**)的微服务。我想在/ms/platform前面加上前缀,以到达位于我的微服务中的实际rest端点(因此/ms/platform/api/scd/secure/**)。我的问题是,即使我将uri设置为localhost:8050,它也将网关uri用作最终目的地(因此lo

我有一个SpringCloudGateway,它位于其他微服务的前面。网关还用作身份验证层。我的网关位于localhost:9000,我希望将流量定向到localhost:8050上具有谓词路径(
/api/scd/secure/**
)的微服务。我想在/ms/platform前面加上前缀,以到达位于我的微服务中的实际rest端点(因此
/ms/platform/api/scd/secure/**
)。我的问题是,即使我将uri设置为localhost:8050,它也将网关uri用作最终目的地(因此
localhost:9000/ms/platform/api/scd/secure/**

我已经试着在SpringCloudGateway上读了很多关于PrefixXPath过滤器如何工作的书,但是我读到的所有内容都表明我的配置应该可以工作

spring:
  cloud:
    gateway:
      routes:
      - id: scd_secure
        uri: http://localhost:8500
        predicates:
        - Path=/api/scd/secure/**
        filters:
        - PrefixPath=/ms/platform
        - GatewaySecurityFilter

我希望在我的GatewaySecurityFilter中,exchange.getRequestURI是
localhost:8050/ms/platform/api/scd/secure/**
,但它最终是
localhost:9000/ms/platform/api/scd/secure/**

如果显式地将uri设置为端口9000,它如何知道转到8050?请尝试使用RewritePath而不是PrefixPath。它还可以更改URI。您是否考虑过使用strip prefix:false?@Spencergib我很抱歉输入错误,URI实际上设置为localhost:8500,请参见上面的更正。我发现我的问题后,多一点阅读,这是有意义的现在。。。我使用我添加的GatewaySecurityFilter来查看新路由的外观,但是该筛选器在传递到定义的uri之前发生,因此我看到了新路由(在前缀XPath筛选器之后),但在uri被使用之前。感谢您的快速建议,虽然我的问题实际上是在提供请求的资源的微服务上