I have Spring Cloud gateway setup to route traffic to various backend services. I also have a fallback route that forwards any unmatched routes to some static content. It works great.
Now I need to expose the gateway's local /actuator/prometheus endpoint for monitoring. By default, this routes to my fallback route, resulting in hitting the actuator endpoint of the fallback service. I need the gateway to serve /actuator/prometheus locally, but I'm not sure how to define this. If I use a URI pointing to the gateway itself, I'll simply wind up in an infinite loop.
cloud:
gateway:
routes:
# Other routes defined...
- id: actuator
uri: http://localhost:8080 # Won't work; infinite loop
predicates:
- Path=/actuator/**
# Fallback route:
- id: web-interface
uri: lb://fallback
predicates:
- Path=/**
How can I configure Spring Cloud Gateway to serve certain routes locally, like /actuator/**, but still have a fallback route for anything else that is not matched? I could replace my fallback route with "/web/**" or something, but I'd like to avoid changing a lot of front-end code.
Adding key detail: The conundrum listed above is specific to the spring-cloud-starter-gateway reactive version of Spring Cloud Gateway. If I use spring-cloud-starter-gateway-mvc, the /actuator/** endpoints are resolved to the gateway itself, without lifting a finger.