Is there a way to target an upstream server in Ingress resource configuration based on request URL query parameter?

5/17/2020

I have scenario; where I want to redirect to different services at back end based on a query parameter value. I have gone through documents but couldn't find any help there.

For example:

if Path=/example.com/?color=red ---> forward request to service--> RED-COLOR-SERVICE:8080
if Path=/example.com/?color=blue ---> forward request to service--> BLUE-COLOR-SERVICE:8080
if Path=/example.com/?color=green ---> forward request to service--> GREEN-COLOR-SERVICE:8080

Thanks

-- Jaraws
kubernetes
kubernetes-ingress
nginx
nginx-ingress

1 Answer

5/17/2020

In general no, the Ingress spec only offers routing on hostname and path. Check the annotation features offered by your specific controller, but I don’t know of any for this off the top of my head.

-- coderanger
Source: StackOverflow