Kong ingress controller 404 when not using /

#1

Hiya Kong Nation,

Here is a super bizarre problem while using kong ingress controller:

Whenever I specify a path other than simply / I get a 404 error:

Here is what I mean:

spec:
  rules:
  - host: demo.c1.website.com
    http:
      paths:
      - backend:
          serviceName: demo
          servicePort: 80
        path: /
  tls:
  - hosts:
    - demo.c1.website.com
    secretName: website.com

I can access my api normally like any ingress controller would let me. { status: 200 }

But if I simply change the path to anything other than / for instance:

spec:
  rules:
  - host: demo.c1.website.com
    http:
      paths:
      - backend:
          serviceName: demo
          servicePort: 80
        path: /test
  tls:
  - hosts:
    - demo.c1.website.com
    secretName: website.com

curling demo.c1.website.com/test will return:
{"status":404,"message":"Not Found"}

/routes and /services are correctly populated

routes

{
            "created_at": 1556026481,
            "destinations": null,
            "hosts": [
                "demo.c1.website.com"
            ],
            "id": "18a23f34-45b9-401f-93f9-b9b790fad6b3",
            "methods": null,
            "name": null,
            "paths": [
                "/test"
            ],
            "preserve_host": false,
            "protocols": [
                "http",
                "https"
            ],
            "regex_priority": 0,
            "service": {
                "id": "0cb46894-7acb-4075-b13a-a36b5153a4a0"
            },
            "snis": null,
            "sources": null,
            "strip_path": false,
            "tags": null,
            "updated_at": 1556026481
        }

Services:

{
            "connect_timeout": 60000,
            "created_at": 1555610749,
            "host": "demo.demo.80",
            "id": "0cb46894-7acb-4075-b13a-a36b5153a4a0",
            "name": "demo.demo.80",
            "path": "/",
            "port": 80,
            "protocol": "http",
            "read_timeout": 60000,
            "retries": 5,
            "tags": null,
            "updated_at": 1555610749,
            "write_timeout": 60000
        }

upstreams

{
            "created_at": 1555610749,
            "hash_fallback": "none",
            "hash_fallback_header": null,
            "hash_on": "none",
            "hash_on_cookie": null,
            "hash_on_cookie_path": "/",
            "hash_on_header": null,
            "healthchecks": {
                "active": {
                    "concurrency": 10,
                    "healthy": {
                        "http_statuses": [
                            200,
                            302
                        ],
                        "interval": 0,
                        "successes": 0
                    },
                    "http_path": "/",
                    "https_sni": null,
                    "https_verify_certificate": true,
                    "timeout": 1,
                    "type": "http",
                    "unhealthy": {
                        "http_failures": 0,
                        "http_statuses": [
                            429,
                            404,
                            500,
                            501,
                            502,
                            503,
                            504,
                            505
                        ],
                        "interval": 0,
                        "tcp_failures": 0,
                        "timeouts": 0
                    }
                },
                "passive": {
                    "healthy": {
                        "http_statuses": [
                            200,
                            201,
                            202,
                            203,
                            204,
                            205,
                            206,
                            207,
                            208,
                            226,
                            300,
                            301,
                            302,
                            303,
                            304,
                            305,
                            306,
                            307,
                            308
                        ],
                        "successes": 0
                    },
                    "type": "http",
                    "unhealthy": {
                        "http_failures": 0,
                        "http_statuses": [
                            429,
                            500,
                            503
                        ],
                        "tcp_failures": 0,
                        "timeouts": 0
                    }
                }
            },
            "id": "dd181c04-f078-4084-8f88-00ae3e6de021",
            "name": "demo.demo.80",
            "slots": 10000,
            "tags": null
        }

What am I missing?

Thanks,
Sarti

#2

I think I see what the problem is.

The ingress path will also go to the same path in my API:

demo.c1.example.com/test would redirect to <api>/test Since this path does not exist in my api I get a 404 error

The expected behavior would be the root path of my api:
demo.c1.example.com/test --> <api>/

How can I fix this behavior?

Thanks,
Sarti

#3

Creating a KongIngress resource with strip_path true fixed the problem…

apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: demo
  namespace: demo
route:
  strip_path: true

But… is there a way to do this directly in the ingress resource?

Thanks,
Sarti

#4

With 0.4.0 version of the Ingress Controller, you strip_path will be set to true by default and should solve this problem.