0
votes

I updated my ingress.yaml by adding a new path e.g. instead of example.com/ i added example.com/dev/. i deleted the old ingress and deployed the new ingress but still my app gets redirected to old example.com and on accessing example.com/dev/ i get "The requested resource was not found on this server." I am using the same old tls certificate since the hostname is still example.com. When i describe my ingress i get :

Name:             example-ingress
Namespace:        dev-env
Address:          
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
  selfsigned-cert terminates example.com
Rules:
  Host                   Path  Backends
  ----                   ----  --------
  example.com  
                         /dev/static   app-svc:80 (172.16.0.29:80)
                         /dev/(.*)     app-svc:8000 (172.16.0.29:8000)
Annotations:             
                         kubernetes.io/ingress.class: nginx
                         nginx.ingress.kubernetes.io/proxy-body-size: 20m
                         nginx.ingress.kubernetes.io/rewrite-target: /$1
Events:                  <none>

my ingress file is :

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: example-ingress
  namespace: prod-env
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    kubernetes.io/ingress.class: "nginx"
spec:
  tls:
    - hosts:
        - example.com
      secretName: selfsigned-cert
  rules:
    - host: example.com
      http:
        paths:
          - path: /dev/static
            backend:
              serviceName: app-svc
              servicePort: 80
          - path: /dev/(.*)
            backend:
              serviceName: app-svc
              servicePort: 8000
status:
  loadBalancer:
    ingress:
      - ip: 192.168.0.19
        hostname: example.com
1
Have you checked in browser incognito mode. TRY private windows in your browser as rewrite might be in cache - Taybur Rahaman
@TayburRahaman HiI just tried that but still the same results. - devcloud
Can you check the the ingress controller pod log and update the question with log - Taybur Rahaman

1 Answers

0
votes

Please apply the same port as 8000 or 80 for both services:

- host: example.com
  http:
    paths:
      - path: /dev/static
        backend:
          serviceName: app-svc
          servicePort: 8000
      - path: /dev/(.*)
        backend:
          serviceName: app-svc
          servicePort: 8000

or

- host: example.com
  http:
    paths:
      - path: /dev/static
        backend:
          serviceName: app-svc
          servicePort: 80
      - path: /dev/(.*)
        backend:
          serviceName: app-svc
          servicePort: 80

Also try to change annotation to: nginx.ingress.kubernetes.io/rewrite-target: $2

Take look: ingress-path, ingress-rewrite-target.