SpringCloudZuul相关配置

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/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值