application.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. server:
  2. port: 6000
  3. spring:
  4. application:
  5. name: gateway
  6. profiles:
  7. active: @profile.active@
  8. cloud:
  9. loadbalancer:
  10. ribbon:
  11. enabled: false
  12. gateway:
  13. # 默认过滤器(对所有 route 均生效)
  14. default-filters:
  15. # 限流配置
  16. - name: MyRequestRateLimiter
  17. args:
  18. # 如果 keyResolver 返回空 key 则拒绝请求返回 403, 默认 true 表示拒绝, false 表示允许访问
  19. deny-empty-key: false
  20. # 自定义的 KeyResolver(从请求 exchange 解析 id 来区分独立的限流单元, id 可以是 userId, remoteAddr, sessionId 等)
  21. key-resolver: "#{@keyResolver}"
  22. # rate-limiter: "#{@myRateLimiter}"
  23. # my-rate-limiter.requestedTokens: 1
  24. rate-limiter: "#{@redisRateLimiter}"
  25. # 令牌桶算法每秒补充的 token 数量(每秒的请求数量)
  26. redis-rate-limiter.replenishRate: 100
  27. # 令牌桶算法的 token 最大数量(每秒的最大请求数量)
  28. redis-rate-limiter.burstCapacity: 150
  29. # 单次请求消费的 token 数量
  30. redis-rate-limiter.requestedTokens: 1
  31. routes:
  32. - id: account-router
  33. # spring-cloud-starter-zookeeper-discovery 提供服务发现功能
  34. uri: lb://account-service
  35. predicates:
  36. - Path=/api/account/**
  37. filters:
  38. - StripPrefix=0
  39. - id: static-router
  40. uri: lb://account-service
  41. predicates:
  42. - Path=/dist/images/**
  43. filters:
  44. - StripPrefix=0
  45. - id: auth-router
  46. uri: lb://account-service
  47. predicates:
  48. - Path=/api/auth/**
  49. filters:
  50. - StripPrefix=0
  51. - id: oauth-router
  52. uri: lb://account-service
  53. predicates:
  54. - Path=/oauth/**
  55. filters:
  56. - StripPrefix=0
  57. - id: user-router
  58. uri: lb://user-service
  59. predicates:
  60. - Path=/api/user/**
  61. filters:
  62. - StripPrefix=0
  63. ###############################################################################
  64. - id: content-router
  65. uri: lb://content-service
  66. predicates:
  67. - Path=/api/content/**
  68. filters:
  69. - StripPrefix=0
  70. - id: timeline-router
  71. uri: lb://content-service
  72. predicates:
  73. - Path=/api/timeline/**
  74. filters:
  75. - StripPrefix=0
  76. - id: search-router
  77. uri: lb://content-service
  78. predicates:
  79. - Path=/api/search/**
  80. filters:
  81. - StripPrefix=0
  82. - id: comment-router
  83. uri: lb://content-service
  84. predicates:
  85. - Path=/api/comment/**
  86. filters:
  87. - StripPrefix=0
  88. - id: mall-router
  89. uri: lb://content-service
  90. predicates:
  91. - Path=/api/mall/**
  92. filters:
  93. - StripPrefix=0
  94. - id: geo-router
  95. uri: lb://content-service
  96. predicates:
  97. - Path=/api/geo/**
  98. filters:
  99. - StripPrefix=0
  100. - id: im-router
  101. uri: lb://content-service
  102. predicates:
  103. - Path=/api/chat/**
  104. filters:
  105. - StripPrefix=0
  106. ###############################################################################
  107. - id: data-router
  108. uri: lb://data-service
  109. #uri: http://192.168.0.39:6005
  110. predicates:
  111. - Path=/api/data/**
  112. filters:
  113. - StripPrefix=0
  114. ###############################################################################
  115. - id: file-router
  116. uri: lb://file-service
  117. predicates:
  118. - Path=/api/file/**
  119. filters:
  120. - StripPrefix=0
  121. ###############################################################################
  122. - id: message-websocket
  123. uri: lb:ws://message-service
  124. predicates:
  125. - Path=/ws/**
  126. - id: message-router
  127. uri: lb://message-service
  128. predicates:
  129. - Path=/api/message/**
  130. ###############################################################################
  131. - id: log-websocket
  132. uri: lb:ws://search-service
  133. predicates:
  134. - Path=/logws/**
  135. - id: search1-router
  136. uri: lb://search-service
  137. predicates:
  138. - Path=/api/search1/**
  139. # gateway:
  140. # globalcors:
  141. # cors-configurations:
  142. # '[/**]':
  143. # allowedOrigins: "*"
  144. # allowedMethods: "*"
  145. # allowedHeaders: "*"
  146. eureka:
  147. instance:
  148. prefer-ip-address: true
  149. client:
  150. register-with-eureka: true
  151. fetch-registry: true