1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- server:
- port: 18002
- # 指定当前服务的名称,这个名称会注册到注册中心
- spring:
- application:
- name: @artifactId@
- cloud: # spring cloud gateway 路由配置方式
- gateway:
- discovery: # 是否与服务发现组件进行结合,通过 serviceId 转发到具体的服务实例。
- locator: # 默认为false,设为true便开启通过服务中心的自动根据 serviceId 创建路由的功能。
- enabled: true
- lowerCaseServiceId: true # 将请求路径的服务名配置改成小写
- x-forwarded:
- enabled: false
- routes:
- - id: user-server # 自定义的路由 ID,保持唯一性
- uri: lb://caimei365-cloud-user # 从注册中心获取服务,且以lb(load-balance)负载均衡方式转发
- predicates:
- - Path=/user/** # 将以/user/开头的请求转发到uri为lb://caimei365-cloud-user的地址上
- - id: commodity-server
- uri: lb://caimei365-cloud-commodity
- predicates:
- - Path=/commodity/** # 将以/commodity/开头的请求转发到uri为lb://caimei365-cloud-commodity的地址上
- - id: tools-server
- uri: lb://caimei365-cloud-tools
- predicates:
- - Path=/tools/** # 将以/tools/开头的请求转发到uri为lb://caimei365-cloud-tools的地址上
- - id: order-server
- uri: lb://caimei365-cloud-order
- predicates:
- - Path=/order/** # 将以/order/开头的请求转发到uri为lb://caimei365-cloud-order的地址上
- # 指定服务注册中心的地址
- eureka:
- instance:
- prefer-ip-address: true # 是否使用 ip 地址注册
- instance-id: ${spring.cloud.client.ip-address}:${server.port} # ip:port
- client:
- service-url: # 设置服务注册中心地址
- defaultZone: http://localhost:18000/eureka/
- #日志配置
- logging:
- file:
- path: /mnt/newdatadrive/data/runtime/cloud-instance/cloud-gateway/logs
- level:
- root: info
|