0
votes

I have been reading about spring cloud gateway for implementing an API gateway in my microservice architecture. I need to block certain URLs which I have been using for some internal operations. However, I have used ignoredServices and ignoredPatterns in gateway as in Zuul, but there is no such thing as this in Spring cloud gateway link. My internal APIs starts with /internal/{something}.

Similarly, I have other doubts regarding servers, Eureka, hysterics and spring configs. Below is the apigateway.yml which I was using with Netflix Zuul.

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

I need help to convert this with the new Spring cloud gateway Implementation.

1
what exactly you can't convert? - Vladlen Gladis
@GVArt How should I ignore patterns using routes and filters with a proper error code? - Vijay

1 Answers

1
votes

SC Gateway works differently from SC Zuul when it comes to route setup - it does not automatically resolve routes based on service id. Only routes that you explicitly define either via properties or Java RouteLocator config will be added. So simply don't add the route definitions for the paths you want to ignore. Also, make sure you use filters to remove any sensitive headers that you don't want to pass forward, as, unlike in Zuul, they will be passed on by default.