Create Nginx Ingress Controller with basic authentication

  1. Create a basic auth file auth:

It’s important the file generated is named auth (actually - that the secret has a key data.auth), otherwise the ingress-controller returns a 503

$ USER=<USERNAME_HERE>; PASSWORD=<PASSWORD_HERE>; echo "${USER}:$(openssl passwd -stdin -apr1 <<< ${PASSWORD})" >> auth

  1. Create a secret

$ kubectl -n longhorn-system create secret generic basic-auth --from-file=auth

  1. Create an Nginx ingress controller manifest longhorn-ingress.yml :
kind: Ingress
  name: longhorn-ingress
  namespace: longhorn-system
    # type of authentication basic
    # name of the secret that contains the user/password definitions basic-auth
    # message to display with an appropriate context why the authentication is required 'Authentication Required '
  - http:
      - path: /
          serviceName: longhorn-frontend
          servicePort: 80
  1. Create the ingress controller: $ kubectl -n longhorn-system apply -f longhorn-ingress.yml

For AWS EKS clusters:

User need to create an ELB to expose nginx ingress controller to the internet. (additional cost may apply)

  1. Create pre-requisite resources:

  2. Create ELB:

© 2019-2024 Longhorn Authors | Documentation Distributed under CC-BY-4.0

© 2024 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.