Zuul Routing w/o Spring-Cloud - spring

Is it possible to define/configure route : endpoint Url mapping in Zuul when spring-cloud / spring boot is not used?

Yes, for services without spring you can specify the url.
More info: http://cloud.spring.io/spring-cloud-static/Camden.SR6/#netflix-zuul-reverse-proxy
zuul:
routes:
users:
path: /myusers/**
url: http://example.com/users_service

Related

Passing sensitive headers in Spring Cloud Gateway

I am migrating my application from Zuul to Spring Cloud Gateway. How can I replace the sensitive header part of below code in Spring Cloud Gateway?
zuul:
routes:
tableau:
path:/test/**
sensitiveHeaders:
url: https://example.com
stripPrefix: false

Path Definition For Each Route in Cloud Gateway

I would like to add a path to each route that I define in spring.cloud.gateway.routes without defining context path, server.servlet.context-path, of each microservice.
E.g.: My gateway runs at port 9090, and my microservice runs at port 8071. The configuration for the microservice in the gateway is like this:
spring:
cloud:
gateway:
routes:
- id: auth
uri: 'http://localhost:8071'
If I hit http://localhost:9090/lorem/ipsum, I can ping the microservice, and see the response. But, I would like to ping the microservice from the gateway as http://localhost:9090/auth/lorem/ipsum.
If I define Path key in predicates, it pings http://localhost:8071/auth/lorem/ipsum, which fails, because the URL in the microservice is not /auth/lorem/ipsum but /lorem/ipsum.
spring:
cloud:
gateway:
routes:
- id: auth
uri: 'http://localhost:8071'
predicates:
- Path=/auth/**
Is there a way to define a path for each microservice or do I have to set server.servlet.context-path for each microservice to achieve what I would like to do?
Spring boot version: 2.6.1 & Spring cloud version: 2021.0.0

How to register non Spring Boot MicroService in Eureka discovery server

I have recently installed a micro service infrastraucture based on Spring Boot + Spring Cloud.
My Spring Boot microservices register in my Eureka server and Zuul automaticaly redirects requests to them.
I have a Drupal content manager that exposes content through REST interface and I'd like it to take part in the discovery rave party. How can I have my drupal register it self in the Eureka server so Zuul redirects the corresponding calls to it?
As an ugly workaround I wonder if I can have automatic discovery and routing running in Zuul while manually configuring some REST paths to be redirected to the drupal server? (Using zuul.routes... property files)
I found that I can add manual zuul routes in bootstrap.yaml
I have tried adding it in the application yaml property files in configuration server but for some reason they are ignored when the Eureka discovery server is working.
Anyway, bootstrap.yaml works. Example:
zuul:
routes:
mta_api:
path: /mta_api/**
url: http://my-non-springboot-rest-service.com/
stripPrefix: false
You could add sidecar to your non-springboot application. This would allow Eureka support.
Source: Dead- http://cloud.spring.io/spring-cloud-static/Edgware.SR4/single/spring-cloud.html#_polyglot_support_with_sidecar
Current: https://cloud.spring.io/spring-cloud-static/Dalston.SR5/multi/multi__polyglot_support_with_sidecar.html

Auto-configure routes with Zuul and Eureka

Through reading various books / tutorials, it appears that it is possible to auto-configure routes in Zuul when using it in combination with Eureka service discovery. That means that I don't have to explicitly add routes to Zuul's application.properties.
So I understand this correctly? Or do I still need to add routes explicitly to Zuul in order it to work as a gateway?
I would like it to automatically create routes from the application name's that are registered with Eureka. Is this possible?
(Note: I have actually tried this, but when I go to http://localhost:8762/routes I just get an error page.)
Sure. In most microservices implementations, internal microservices endpoints are not exposed outside. A set of public services will be exposed to the clients using an API gateway.
The zuul proxy internally uses the Eureka Server for service discovery.
I would like it to automatically create routes from the application name's that are registered with Eureka. Is this possible?
Sure. I will show you gateway example.
1. Create your service project (user-service)
create application.properties file
# --- Spring Config
spring:
application:
name: OVND-USER-SERVICE
# Eureka client
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URL:http://localhost:8761/eureka/}
2. Setting up Zuul project (Gateway-service)
1.#EnableZuulproxy to tell Spring Boot that this is a Zuul proxy
#SpringBootApplication
#EnableZuulProxy
#EnableDiscoveryClient
public class GatewayServiceApplication {
2.create an application.properties file
# =======================================
# Gateway-service Server Configuration
# =======================================
# --- Spring Config
spring:
application:
name: gateway-service
server:
port: ${PORT:8080}
# Eureka client
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URL:http://localhost:8761/eureka/}
zuul:
host:
routes:
## By default, all requests to user service for example will start with: "/user/"
## What will be sent to the user service is what comes after the path defined,
## So, if request is "/user/v1/user/tedkim", user service will get "/v1/user/tedkim".
user-service:
path: /user/**
service-id: OVND-USER-SERVICE
another-service:
path: /another/**
service-id: OVND-ANOTHER-SERVICE
Eureka website ( localhost:8761 )
Yes. You can integrate Zuul with Eureka and configure the routes based on application names registered in Eureka. Just add the following configuration to Zuul application:
zuul:
ignoredServices: "*"
routes:
a-service: /a-service/**
b-service: /b-service/**
c-service: /c-service/**
d-service: /d-service/**

Zuul filter requests

I am using Zuul as reverse proxy deployed as a service using Spring Boot. And I have a configuration like:
zuul:
routes:
home:
path: /**
url: localhost:8080
But I want to use the /routes,/info,/health endpoints of the zuul server. Also I want add some endpoints to the zuul server. The problem is that I lost those endpoints because all requests are routed to localhost:8080.
ignoredPatterns in the latest version of ZUUL can help prevent reaching the /** mapping:
zuul:
ignoredPatterns: "/routes/**,/info/**,/custom/**"

Resources