我试图通过使用spring-cloud-gateway构建一个带有负载平衡器的网关但是当我点击gateway时,它给我404,而不是将我路由到eureka
中的注册服务。我不想使用自动发现功能,所以我使用手动路由。
我的代码上传在这里:https://github.com/gry77/poc-spring-cloud-gateway
如何解决这个问题?
从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}