Is there a way we can manipulate a header value received from an upstream server in an ingress resource?

5/17/2020

I have following urls pointing to an Ingress resource:

https://example.com/USA/my-app
https://example.com/UK/my-app

I have written an ingress configurations to target different services based up the country in URI:

host: example.com
    path: /USA(/|$)(.*)$  # Application context of upstream server is /my-app 
    backend:
      serviceName: USA-REGION-SERVICE
      servicePort: 80
    path: /UK(/|$)(.*)$  # Application context of upstream server is /my-app
    backend:
      serviceName: UK-REGION-SERVICE
      servicePort: 80 

And, I rewrite the target using ingress annotation as:

nginx.ingress.kubernetes.io/rewrite-target: /$2

The problem I am face here is with JSESSIONID cookie; the upstream servers returning the set-cookie header with path /my-app which is right; however browser points to paths /USA/my-app or /UK/my-app.

As, a result I loose the session generated and returned by upstream servers as set-cookie header and users log out soon they send another request.

Is there any way I can update JSESSIONID response header? Or, there is problem with the way I am trying it?

-- Jaraws
kubernetes
kubernetes-ingress
nginx-ingress

0 Answers