kubernetes / ingress-nginx

Ingress NGINX Controller for Kubernetes
https://kubernetes.github.io/ingress-nginx/
Apache License 2.0
17.6k stars 8.27k forks source link

sticky session not set for host in server-alias annotation #6448

Closed LuckySB closed 3 years ago

LuckySB commented 4 years ago

NGINX Ingress controller version: v0.34.1 Kubernetes version (use kubectl version): v1.17.7

Environment:

What happened:

Sticky session not set for alias server name

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/affinity-mode: persistent
    nginx.ingress.kubernetes.io/server-alias: my-alias.prod.local
    nginx.ingress.kubernetes.io/session-cookie-change-on-failure: "true"
    nginx.ingress.kubernetes.io/session-cookie-expires: "86400"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "86400"
    nginx.ingress.kubernetes.io/session-cookie-samesite: Strict
  name: test
spec:
  rules:
  - host: www.prod.local
    http:
      paths:
      - backend:
          serviceName: backend
          servicePort: 8080
        path: /

What you expected to happen:

curl -v -I www.prod.local return Set-Cookie: INGRESSCOOKIE=16501c11643a3884bfafcb3576381442; header but curl -v -I my-alias.prod.local return answer without Set-Cookie

Session cookie should return for requests to server-alias name.

Akibbalkhi commented 11 months ago

This does not work when we set multiple serverAlias: nginx.ingress.kubernetes.io/server-alias: test1.sprinklr.com test.sprinklr.com

but works if just one serveralias is set : nginx.ingress.kubernetes.io/server-alias: test1.sprinklr.com

@nic-6443 will need your help to overcome this issue

our main motive is to reduce nginx.conf size.