I have an nginx-ingress calling a custom auth-service
before sending requests to the backend service, using this simple ConfigMap and Ingress:
apiVersion: v1
kind: ConfigMap
metadata:
...
data:
global-auth-url: auth-service-url:8080/authenticate
global-auth-method: GET
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
...
spec:
rules:
- host: host1
http:
paths:
- backend:
serviceName: backend-service
servicePort: 8080
Now I need something different.
How can I send requests, all with the same "Host" header, through different flows, one with auth-service and connected to backend-service1
and the other without any authentication and connecting to backend-service2
?
To be clear, and using the custom header "Example-header: test"
- If "Example-header" is "test", authenticate via my
auth-service
before sending tobackend-service
, as it's done now. - If "Example-header" is not defined, I want to send requests to a different backend service and do not use
auth-service
in the process.
I tried a couple of things, namely having 2 Ingresses, one with global-auth-url
and the other with nginx.ingress.kubernetes.io/enable-global-auth: "false"
but the auth-service is always called.
Can I do this with NGINX, or do I have to use Istio or Ambassador?