简体   繁体   English

带有尤里卡返回 404 的 Spring Cloud Gateway 2.5

[英]Spring cloud gateway 2.5 with eureka return 404

I'm trying to build a gateway with load balancer by using spring-cloud-gateway But when I hit gateway, it gives me 404 instead of routing me to the registered service in eureka我正在尝试使用 spring-cloud-gateway 构建带有负载均衡器的网关但是当我点击网关时,它给了我 404 而不是将我路由到尤里卡中的注册服务

I don't want to use auto-discover feature, so I use manual routing instead.我不想使用自动发现功能,所以我使用手动路由。

my code is uploaded here : https://github.com/gry77/poc-spring-cloud-gateway我的代码在这里上传: https : //github.com/gry77/poc-spring-cloud-gateway

How can I fix it ?我该如何解决?

Got answer from github, I must include ReWritePath to get it works从 github 得到答案,我必须包含 ReWritePath 才能使其正常工作

spring:
  application:
    name: api-gateway
  cloud:
    gateway:
      discovery:
        locator:
          lower-case-service-id: true
          enabled: false
      routes:
        - id: my-service
          uri: lb://my-service
          predicates:
            - Path=/service/**
          filters:
            - RewritePath=/service(?<segment>/?.*), /${segment}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM