Issue
I am working on a spring microservice application. My application uses api gateway, zuul proxy, spring web and is deployed on openshift.
I have the following config in my application.properties file:
zuul.routes.service-name.path=/test/aos/v1/**
zuul.routes.service-name.stripPrefix=false
zuul.routes.service-name.serviceId=service-name
I get the following error when hitting the api @ https://URL.com/test/aos/v1/info:
{
"timestamp": "2021-06-20T23:34:36.862+0000",
"status": 404,
"error": "Not Found",
"message": "Not Found",
"path": "/info"
}
I checked if zuul is failing to register by going to actuator/mappings
and this mapping shows there. So all good there.
Also, if I call the backend API container in OCP directly @ https://CONTAINER_URL.com/test/aos/v1/info then I get the expected result.
So I am understanding that zuul is not able to find the url of the backend api container. Why could that be? The app does not use netflix eureka and instead relies completely on openshift registry.
I cannot go into my standup with this bug standing..... internal screams
Solution
There needs to be a server list or URL mapping against the target service that needs to be reached as per the configured serviceId which is named as "service-name"
Along with other settings add the following -
service-name.ribbon.NIWSServerListClassName=com.netflix.loadbalancer.ConfigurationBasedServerList
service-name.ribbon.listOfServers= https://example1.com,http://example2.com
or remove the serviceId config and add the URL for your container as -
zuul.routes.service-name.url=https://example.com/
Answered By - Dev Utkarsh
Answer Checked By - Robin (JavaFixing Admin)