Skip to content

Basic Auth - 401 Unauthorized #807

Description

@zurrehma

Hi,
I am trying to enable basic auth for my HAproxy ingress resource but each time i am getting below error.

curl -u myuser:mypassword https://example.com/ -k
<html><body><h1>401 Unauthorized</h1>
You need a valid user and password to access this content.
</body></html>
kubectl create secret generic haproxy-credentials `
  --from-literal=myuser=$1$yFwoa5bC$S69wgO19hcVEWUNMsgbRj. `
  -n observability

My Config:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  namespace: my-namespace
  annotations:
    # kubernetes.io/ingress.class: haproxy

    # 🔐 Basic Auth
    haproxy.org/auth-type: basic-auth
    haproxy.org/auth-secret: my-namespace/haproxy-credentials 
    haproxy.org/auth-realm: "Protected OTEL"
    acme.cert-manager.io/http01-edit-in-place: "true"
    cert-manager.io/cluster-issuer: letsencrypt-prod
    ssl-redirect: "true"

spec:
  ingressClassName: haproxy
  tls:
  - hosts:
    - example.com
    secretName: my-tls
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-svc
            port:
              number: 4310

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions