Kong ingress controller render static applications

Hello,

We’ve recently adopted the use of Kong in our Kubernetes cluster using the Kong ingress controller. We’re hoping to be able to use Kong for all of our gateway requirements.

I have an authentication server running on /oauth/admin this routes traffic to the service. Here is my ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: sso
namespace: sso
spec:
rules:
-
http:
paths:
-
backend:
serviceName: pingfederate
servicePort: 9999
path: /oauth/admin

Whenever I hit that endpoint Kong returns a binary file. When I add an NGINX container to the pod it works but is very slow. I’ve seen that you can change the nginx_kong.lua to get around this in Kong outside of Kubernetes ( https://docs.konghq.com/0.11.x/configuration/#serving-both-a-website-and-your-apis-from-kong) but nothing for the ingress controller.

Have I missed something or is it not possible?

Many thanks

Alex

What you are looking for is KongIngress resource and setting the stirpPath property to false (default is true):

@hbagdi thanks for the response.

I’ve set stripPath to false which has allowed me to remove the NGINX container. However, Kong is still returning the binary files of the application not rendering the page. Any ideas?

When I curl the endpoint I get this:

curl -I http://$PROXY_IP/oauth/admin
curl: (8) Weird server reply

That seems a problem with the pingfederate service that you’ve deployed.

If you port-forward to that service, what response do you get when you hit it at /oauth/admin? Do you get back a binary or an HTML file?

I get a binary file back. When I set the path to a CSS file in pingfederate Kong returns that like I’d expect from a standard API call. When I hit the standard /oauth/admin endpoint it can’t seem to figure out how to return the other files.

I’ve put ping federate behind a load balancer and it is rendering fine. I’m guessing it must be how pingfederate is returning files Kong can’t understand it?

When you directly load /oauth/admin, without Kong in the middle, does it load a binary file or an HTML page as you would expect?

It loads HTML pages as I’d expect

Okay, can you share the Ingress and KongIngress resource that you’ve created to proxy this traffic? It seems like a configuration error in one of those two.

Hello,

Sorry for the slow reply. My ingress is:

module "ping_ferate_kong_route" {
  source = "../../modules/kubernetes_ingress"

  annotations_map   = {}
  ingress_name      = "sso"
  ingress_namespace = module.sso_namespace.name
  ingress_paths = [
{
  path         = "/oauth/admin"
  service_name = var.ping_federate_service_selector
  service_port = 9999
},
{
  path         = "/pingfederate/"
  service_name = var.ping_federate_service_selector
  service_port = 9999
},
{
  path         = "/app"
  service_name = var.ping_federate_service_selector
  service_port = 9999
},
{
  path         = "/favicon.ico"
  service_name = var.ping_federate_service_selector
  service_port = 9999
}
  ]
}

Which is going to this module:

module "ping_federate_service" {
  source            = "../../modules/kubernetes_service"
  service_name      = var.ping_federate_service_selector
  service_namespace = module.sso_namespace.name
  service_ports = [
    {
      name        = "pf-console"
      port        = 9999
      protocol    = "TCP"
      target_port = 9999        },
    {
      name        = "pf-runtime"
      port        = 9031
      protocol    = "TCP"
      target_port = 9031
    }
  ]
}