簡體   English   中英

使用Spring Cloud Gateway實現Micorservice API網關

[英]Micorservice API Gateway Implementation with Spring Cloud Gateway

我一直在閱讀有關在我的微服務架構中實現API網關的Spring Cloud Gateway。 我需要阻止某些內部操作使用的某些URL。 in gateway as in Zuul, but there is no such thing as this in Spring cloud gateway link . 但是,我像Zuul 在網關中使用了 ,但是在Spring雲網關link中沒有這樣的事情。 我的內部API以/ internal / {something}開頭。

同樣,對於服務器,Eureka,歇斯底里和彈簧配置,我還有其他疑問。 以下是我與Netflix Zuul一起使用的apigateway.yml。

zuul:
  ignoredServices: '/**/internal/**'
  sensitive-headers: Cookie,Set-Cookie
  routes:
    microservice1:
      service-id: microservice1
    microservice2:
      service-id: microservice2
  host:
    connect-timeout-millis: 10000
    #10 mins socket timeout
    socket-timeout-millis: 600000

management:
  security:
    enabled: false
health:
  config:
    enabled: false

server:
  tomcat:
    #50MB size limit
    max-http-post-size: 5048576
  compression:
    enabled: true
    mime-types: application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css

eureka:
  instance:
    prefer-ip-address: true
    lease-renewal-interval-in-seconds: 15
    lease-expiration-duration-in-seconds: 45
    metadata-map:
      management:
        port: ${management.port:9080}
  client:
    registryFetchIntervalSeconds: 15

hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: false
        isolation:
          strategy: THREAD
          thread:
            timeoutInMilliseconds: 10000

spring:
  http:
    multipart:
      max-file-size: 50MB
      max-request-size: 50MB

我需要幫助,以使用新的Spring雲網關實現將其轉換。

在路由設置方面,SC Gateway與SC Zuul的工作原理不同-它不會根據服務ID自動解析路由。 僅添加通過屬性或Java RouteLocator配置明確定義的路由。 因此,只需不要為要忽略的路徑添加路由定義。 另外,請確保使用過濾器刪除您不想轉發的所有敏感標頭,因為與Zuul不同,默認情況下會將其傳遞。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM