The port would lost before login when deployed on a kubenate

I deploy a empty jmix 2.0.1 project on a kubernate cluster with such config files.
when I open by ingress like http://my.domain:32789/lost-port,it will redirect to http://my.domain/lost-port/login,and it won’t happen when I use service nodePort
(I set server.servlet.context-path= /lost-port in application.properties)

kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
  name: lost-port-loadbalancer
  namespace: jmix-test
  annotations:
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/affinity-mode: persistent
    nginx.ingress.kubernetes.io/session-cookie-expires: '172800'
    nginx.ingress.kubernetes.io/session-cookie-hash: sha1
    nginx.ingress.kubernetes.io/session-cookie-max-age: '172800'
spec:
  rules:
    - http:
        paths:
          - path: /lost-port
            pathType: Prefix
            backend:
              service:
                name: lost-port-service
                port:
                  number: 8080

---
kind: Service
apiVersion: v1
metadata:
  name: lost-port-service
spec:
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
      nodePort: 31424
  selector:
    app: lost-port-app
  type: NodePort
  

Hello @tzh1234,

Jmix itself should not have any impact on the port definition. If you try to set custom port for local app it won’t be lost.

If this is not the case and Jmix app itself breaks something, please provide some example projeсt, steps to reproduce the issue with expected and actual behaviour (and all configs if the problem is reproduced in cluster only).

Simple k8s deployment described in documentation. More advanced cases is a matter of k8s setup, about which more qualified answers will be given by Kubernetes specialists.

However, if I understand you correctly, maybe this issue will be usefull in your case because

An Ingress does not expose arbitrary ports or protocols

according to k8s documentation.

Regards,
Dmitry

I test a empty project only with spring boot and spring security.It has same issue.And then I wrote a Filter to log all header of request.I found the ’ X-Forwarded-Port’ is 80 instead of the the port I configured.Maybe the reason at here and my ingress configuration is wrong. Thank you very much.

1 Like