Kong ingress controller not routing based on host header

I am starting off with kong ingress controller and got this basic ingress in place for host header based routing. I can route requests to service.foo.com but not to service.bar.com , I keep seeing url not found error service.bar.com has its DNS records in place, also I could make a curl request to its service endpoint from within the app container. kong logs show no targets could be found for kubernetes service which is confusing to me since I can make a curl request to the endpoint. I port-forwarded kong-proxy and checked the routes locally on http://localhost:8080/routes through kong-admin. open to more suggestions

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: multi-domain-ingress
  annotations:
    konghq.com/plugins: kong-custom-query-routing,tcp-log-plugin
    konghq.com/https-status-redirect-code: "301"
    konghq.com/strip-path: "true"
    konghq.com/preserve-host: "true"
    konghq.com/protocols: http,https
    konghq.com/http-forwarded: "preserve"
spec:
  tls:
    - hosts:
        - service.foo.com
      secretName: secret-cert  
  ingressClassName: kong
  rules:
    - host: service.foo.com
      http:
        paths:
          - path: /a
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-app
                port:
                  number: 80
          - path: /b
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-svc
                port:
                  number: 80
          - path: /c
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-svc
                port:
                  number: 80
          - path: /health
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-svc
                port:
                  number: 80
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: certbot
                port:
                  number: 80
   - host: service.bar.com
      http:
        paths:
          - path: /a
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-frontend-svc
                port:
                  number: 80
          - path: /b
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-frontend-svc
                port:
                  number: 80
          - path: /c
            pathType: ImplementationSpecific
            backend:
              service:
                name: frontend-svc
                port:
                  number: 80
          - path: /d
            pathType: ImplementationSpecific
            backend:
              service:
                name: flask-frontend-svc
                port:
                  number: 80
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: another-service
                port:
                  number: 80

it worked after changing strip-path to false. when it was true, it was stripping the paths in the HTTP request and since there’s no ‘/’ in the ingress rules, the request was failing

1 Like