I hava eureka server at eureka-server.com host and application with appId facade registered at server. Facade application has /users endpoint. Can I call /users endpoint through Eureka server something like this eureka-server.com/facade/users ?
No, Eureka can't proxy your calls through it, it's pure service discovery. But you can add a separate Zuul service with reverse proxy filtering which uses Eureka client to discover routes. Spring Cloud Netflix Zuul component has this out of the box.
Related
I have used spring cloud discovery server for kubernetes based on this release notes.
https://spring.io/blog/2021/10/26/new-features-for-spring-cloud-kubernetes-in-spring-cloud-2021-0-0-m3
A GET request sent to http://localhost/apps is also returning JSON array of available services as expected.
https://docs.spring.io/spring-cloud-kubernetes/docs/2.1.0-M3/reference/html/#apps
My question is how do I configure Feign Client or RestTemplate to consume the endpoint services provided by the Discovery Server.
(Feign Client or RestTemplate) does not seems to resolve the service names.
We are planning to build a reverse proxy server for our enterprise to make some external API calls.
Currently, our microservice applications are hosted on the PCF environment. For any external (on the internet) calls, we make use of the PCF proxy server to communicate.
Now my use-case is to build a reverse proxy server(Spring Zuul) to route to external APIs through the PCF proxy. However, the microservice applications wouldn't pass any proxy information on the request to the zuul server. So, this needs to be added by Spring Zuul reverse proxy server.
Problem:
How to add HTTP proxy details to the coming request from zuul server?
Any documentation also would be really helpful.
I have a spring-boot client app deployed in a customer network and I want to use SBA as a GUI for its actuator endpoints. I cannot use register-client-applications to register the app, mainly because the client app has no connectivity to SBA (its behind a firewall).
Is there a way how to add a client to SBA manually?
You can add use a static configuration for spring cloud's discovery client. So there is no need that the client reach the sba server. See http://codecentric.github.io/spring-boot-admin/current/#spring-cloud-discovery-static-config
Im working with Spring Cloud Zuul + Eureka Server. i know that Zuul will create routes dynamically when there is a service registered on Eureka and it will be route using their Service ID. Is it possible to delegate routes to group services ?
for example i have 2 services that i want to group:
server.port=8081
spring.application.name=company-account-api
server.port=8082
spring.application.name=company-transaction-api
eureka config
spring.application.name=api-discovery
spring.cloud.config.uri=${CONFIG_SERVER_URL:http://localhost:8888}
on Zuul is it possible define a route where i can access the 2 services registered on eureka ?
server.port=9090
spring.application.name=api-gateway
eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.serviceurl.defaultzone=http://localhost:8761/eureka
zuul.routes.company-api=/company-**
so when i access http://localhost:9090/company-api/company-account-api & http://localhost:9090/company-api/company-transaction-api the service registered on eureka will be available
You can achieve this with the following config
zuul.ignored-services=*
zuul.routes.company-account-api.serviceId=company-account-api
zuul.routes.company-account-api.path=/company-api/company-account-api/**
zuul.routes.company-transaction-api.serviceId=company-transaction-api
zuul.routes.company-transaction-api.path=/company-api/company-transaction-api/**
Explanation:
zuul.ignored-services=* This will supress the default config
zuul.routes.company-account-api.serviceId=company-account-api
zuul.routes.company-account-api.path=/company-api/company-account-api/**
What is exposed to public is /company-api/company-account-api/** which will be internally mapped to company-account-api service.
If you are not using service discovery then you can do it using url instead of service name
zuul.routes.company-account-api.url=http://accountapihost:accountapiport
zuul.routes.company-account-api.path=/company-api/company-account-api/**
Lets consider the following situation.This example will only have urls containing localhost. I have a zuul proxy setup and lets say its running on port 8080. So
Zuul proxy-
localhost:8080
I have an eureka server setup running on port 81.
Eureka server-
localhost:8081.
I have an application lets call it by name-example which is a REST web service. Its running on 3 different ports 82,83 and 84. All 3 instances are registered with eureka server. I have a filter setup in zuul for the uri /example.
So i expect consumers to call the zuul proxy at locahost:8080/example.
Now, in the application example for the request mapping /example, there is a controller setup.
So what i want to do is basically have the consumers call localhost:8080/example and route that request to localhost:8082/example, localhost:8083/example, localhost:8084/example . I know how to load balance using ribbon and eureka and have all the appropriate properties set to achieve that.
zuul.routes.example.serviceid=example
ribbon.eureka.enabled=true.
What i want to do is have ribbon look up the list of url(s) from eureka server and then call localhost:8082/example rather localhost:8082.
Is this possible?
Thank you in advance.
You need to specify the path & serviceId
zuul:
routes:
examplepath:
path: /example/**
serviceId: name-example
stripPrefix: false
The serviceId is the name registered with Eureka. Hope you are specifying Eureka server details in you Zuul gateway.