Warm tip: This article is reproduced from serverfault.com, please click

How do I use Ingress with basic auth but only for certain routes?

发布于 2020-11-16 13:04:33

How do I make an ingress with basic auth on every path of the domain except on one. My ingress looks like this:
apiVersion: extensions/v1beta1

kind: Ingress
metadata:
  name: frontend-ingress
  namespace: dev
  labels:
    app: x
  annotations:
    kubernetes.io/ingress.global-static-ip-name: x.x.x
    ingress.kubernetes.io/auth-secret: "basic-auth"
    ingress.kubernetes.io/auth-type: "basic"
spec:
  rules:
  - host: x.x.x
    http:
      paths:
      - path: /
        backend:
          serviceName: hello
          servicePort: 80 

What i wanna make is to have basic auth on every path except on /successfull_login , when I hit x.x.x/successfull_login not to require credentials. I tried making a new Ingress just with that path that doesn't use basic auth but still it require basic auth.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-successfull-login
  namespace: dev
  labels:
    app: x
  annotations:
    kubernetes.io/ingress.global-static-ip-name: x.x.x
spec:
  rules:
  - host: x.x.x
    http:
      paths:
      - path: /successfull_login
        backend:
          serviceName: hello
          servicePort: 80

How do i do it?

Questioner
Шурбески Христијан
Viewed
0
community wiki 2020-12-01 16:57:52

As mentioned in comments, the solution adopted was separate the application view in a new docker image, also a new deployment and service was created to this new piece of code.