I have a KongIngress
object configuration attributes regarding to Ingress resource which call to kong as an Ingress controller. I actually have this configuration:
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: echo-site-ingress
namespace: hello-world
annotations:
kubernetes.io/ingress.class: "kong"
proxy:
protocols:
- http
- https
# path: /
route:
methods:
- POST
- GET
strip_path: true
preserve_host: true
---
#My Ingress resource
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: kong
plugins.konghq.com: helloworld-customer-acceptance-basic-auth, hello-world-customer-acceptance-acl
name: echo-site-ingress
namespace: hello-world
spec:
rules:
- host: hello-world.bgarcial.me
http:
paths:
- backend:
serviceName: echo
servicePort: 80
path: /
tls:
- hosts:
- hello-world.bgarcial.me
secretName: letsencrypt-prod
The questions are:
What are doing in my kind:KongIngress
object resource the strip_path
and preserve_host
attributes?
I read the documentation here, but it is not clear for me:
Regarding to strip_path
I see this one:
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Defaults to true. but as we can see, I am not using the path attribute inside my KongIngress object (I commented for illustration purposes about my question)
So, how strip_path
attribute value is applied here?
It is because I am using in my Ingress resource the path: /
attribute and my Ingress and my KongIngress resources are working together?
I really don't have a clue about it, but I would like to know how is this about behind scenes.
When preserv_host
annotation is enabled the host
header of the request will be sent as is to the Service in Kubernetes. Well explained in the documentation.
strip_path
can be configured to strip the matching part of your path from the HTTP request before it is proxied.
If it is set to "true"
, the part of the path specified in the Ingress rule will be stripped out before the request is sent to the service. For example, when it is set to "true"
, the Ingress rule has a path of /foo
and the HTTP request that matches the Ingress rule has the path /foo/bar/something
, then the request sent to the Kubernetes service will have the path /bar/something
. So when you use curl $YOUR_HOST/foo/bar/something
, under real path value in the output you will see /bar/something
And if set to false
no path manipulation is performed and in your case can be changed to such as there is no manipulation to be done.