Spring Cloud Gateway Remove url Prefix
- 2021-10-27 07:31:09
- OfStack
Spring Cloud Gateway Remove url Prefix
Mainly add one route, and other configurations remain unchanged
routes:
- id: service_customer
uri: lb://CONSUMER
order: 0
predicates:
- Path=/customer/**
filters:
- StripPrefix=1
- AddResponseHeader=X-Response-Default-Foo, Default-Bar
The newly added StripPrefix can accept a non-negative integer, and the corresponding specific implementation is StripPrefixGatewayFilterFactory. From the name, it can be seen that its function is to remove prefixes, and that integer is the corresponding number of layers.
Specific to this example, we accessed the/customer/hello/windmt through Spring Cloud Gateway, so when the gateway service forwards the request backward, the/customer will be removed, and the microservice will receive the/hello/windmt.
Description of Common Configuration Parameters Prefixed with eureka. instance in Spring Cloud
参数名 | 说明 | 默认值 |
---|---|---|
preferIpAddress | 是否优先使用IP地址作为主机名的标识 | false |
leaseRenewalIntervalInSeconds | Eureka客户端向服务端发送心跳的时间间隔,单位为秒 | 30 |
leaseExpirationDurationInSeconds | Eureka服务端在收到最后1次心跳之后等待的时间上限,单位为秒。超过该时间之后服务端会将该服务实例从服务清单中剔除,从而禁止服务调用请求被发送到该示例上 | 90 |
nonSecurePort | 非安全的通信端口号 | 80 |
securePort | 安全的通信端口号 | 443 |
nonSecurePortEnabled | 是否启用非安全的通信端口号 | true |
securePortEnabled | 是否启用安全的通信端口号 | |
appname | 服务名,默认取spring.application.name的配置值 | unkonwn |
hostname | 主机名,不配置的时候将根据操作系统的主机名来获取 |
Note:
org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean
Class, you can view the default values of each parameter.