3

I have created an ingress controller configuration with following path definitions:

paths:
   - path: (USA)/my-app/(.*)$
     ...............
   - path: (UK)/my-app/(.*)$

The problem happening here is when I don't set the following annotation;

nginx.ingress.kubernetes.io/session-cookie-path

I get regular expression in INGRESSCOOKIE path as:

cookie-name: INGRESSCOOKIE --------cookie-path: /(USA)/my-app/(.*)$

This is coming from the given path i.e. /(USA)/my-app/(.*)$.

As a result this response cookie from Ingress doesn't go back to Ingress for any subsequent request for http://USA/my-app/?id=1. (as HTTP request path differs from path in INGRESSCOOKIE)

And because of this HTTP request at times hit a different upstream server and user logs out; as session id in request is generated by a different server managed through the same load balancer.

I then tried setting annotation as:

nginx.ingress.kubernetes.io/session-cookie-path= /$1/my-app

But $1 doesn't actually resolve here; probably we cant give expressions in session-cookie-path.

Is there anything I am not doing in a right way here? Or, I should try something else to achieve session affinity.

Thanks

G Jones
  • 357
  • 1
  • 6
Jaraws
  • 581
  • 1
  • 7
  • 24

1 Answers1

0

I know this is pretty old but wanted to share my view anyway.

For your issue, you might want to try the following annotation: nginx.ingress.kubernetes.io/use-regex

Please remove "session-cookie-path" from annotations as Session Cookie Paths doesn't support regex

For more information, please visit below links:

https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#use-regex https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/ https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#cookie-affinity

dinesh
  • 1
  • 1