Greetings, I want to hook various web applications into paths, for example /app1, /app2 etc. using Kong inside Kubernetes with kong Ingress Controller.
Currently, I do this using Ingress and KongIngress, like so (testing using the socks-shop Kubernetes demo application).
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: demo-ingress
namespace: sock-shop
annotations:
configuration.konghq.com: pathstripper
spec:
rules:
- host: www.my.com
http:
paths:
- path: /socks
backend:
serviceName: front-end
servicePort: 80
---
apiVersion: configuration.konghq.com/v1
king: KongIngress
metadata:
name: pathstripper
namespace: sock-shop
proxy:
path: /
preserve_host: true
route:
strip_path: true
So far so good, but two issues come up:
- Visiting
/socksleads to it loading the / of the web application, but it cannot find files under its root (like/js,/cartor/catalogue) because the web browser is still using the basepathwww.my.com/instead ofwww.my.com/socks/.
How to fix this?
As a hack, I added routes for /cart, /catalogue (because the JS application believes it has the webroot for itself) but obviously this does not scale…
- Visiting
/socks/index.htmlwith the above-mentioned hack works and all the paths are fine, but visiting/socksdoes not work (does not find its static resources under/jsetc. which are reachable under/socks/js/bla.js).
How to add a redirect from /socks to /socks/index.html ?
As a hack, using the Kong-API directly, I added a second service homed under /index.html and a route at /socks with regex_priority 1 (so that it matches only on direct match on /socks/ not on /socks/js/jquery.js for example). But I cannot seem to transform this solution from curl Kong-API calls to KongIngress and Ingress objects in Kubernetes - it just won’t create a second Kong Service (why? maybe because it creates just 1 service per backend pod/container - but dont know exactly - any way to make it create a 2nd Kong Service?).
How to solve this overall issue properly?
These two issues seem related. Totally stumped - need help please!
Thanks