bootstrap.yml相关配置
server:
port: 9904
spring:
profiles:
active: dev
application:
name: api-gateway
cloud:
config:
discovery:
enabled: true
serviceId: config-server #配置中心
label: api-gateway
eureka:
instance:
prefer-ip-address: true
instance-id: ${spring.cloud.client.ipAddress}:${server.port} #实例信息
zuul:
prefix: /api ##URI中增加"/api"作为前缀
stripPrefix: true #为true时,使prefix前缀生效;false时,禁用前缀
add-host-header: true #网关在路由转发前为请求设置HOST头信息,默认为false
retryable: false #该值可以关闭如ribbon.ConnectTimeout等的重试机制,可以指定路由关闭重试机制,如:zuul.routes.<router>.retryable=false
#routes:
#customSensitiveHeaders: false #是否过滤掉HTTP请求头信息中的一些敏感信息,默认为false,建议不要修改该值,对有请求头需求的服务单独设置,例如:zuul.routes.<router>.customSensitiveHeaders=true€’
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000 #该参数可以用来设置API网关中路由转发请求的HystrixCommand执行超时时间。当路由转发请求的命令执行时间超过该配置值之后,Hystrix会将该执行命令标记为TIMEOUT并抛出异常,zuul会对该异常进行处理并返回“com.netflix.zuul.exception.zuulException”
ribbon:
ConnectTimeout: 5000 #该参数用来设置路由转发请求的时候,创建请求连接的超时时间,当该值小于hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds时,若出现连接超时,【会自动进行重试路由请求】。如果大于,则按hystrix处理
ReadTimeout: 5000 #原理同ribbon.ConnectTimeout,该值表示读取超时时间
---
spring:
profiles: dev
cloud:
config:
profile: dev
eureka:
client:
serviceUrl:
defaultZone: http://ip1:9902/eureka/,http://ip2:9902/eureka/