selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
nginx-ldap-auth logo

Self-host nginx-ldap-auth

release-0.0.5

LDAP authentication reference for NGINX

AlphaOpen SourceBSD-2-Clause
Updated3 years ago
LanguagePython
Setup difficultyAdvanced
Stars
709
Ports
8888 (ldap-auth daemon HTTP listener), 8081 (NGINX/NGINX Plus listener for authenticated requests), 9000 (Sample backend application)
Requires
OpenLDAP or Microsoft Active Directory, Python, Python-ldap
Install with Docker

What is nginx-ldap-auth?

This NGINX, Inc. project shows how to add LDAP user authentication to applications behind NGINX or NGINX Plus. It supplies a Python daemon that sits between NGINX's auth_request module and an LDAP directory (OpenLDAP or Active Directory), a test backend, and a ready-to-use NGINX config. The code is a reference model, not production-ready, but demonstrates cookie and basic auth, STARTTLS, result caching, and flexible LDAP search filters. Default ports are 8888 for the daemon, 8081 for NGINX, and 9000 for the sample backend. You can run it via Docker, directly with Python 2 or 3, or with the included control script.

Should you self-host nginx-ldap-auth?

nginx-ldap-auth scores 43/100 on selfhost.directory (how scoring works) and ranks #31 of 40 in Authentication. It has 709 GitHub stars.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is advanced: plan for several services and some ongoing maintenance. It is BSD-2-Clause-licensed and written mostly in Python.

Its closest alternative on selfhost.directory is keycloak (86/100, 37 577 stars). It scores higher overall, so compare the two before you pick. See nginx-ldap-auth vs keycloak side by side.

Features

  • Authentication Caching
  • Cookie-based Authentication
  • Customizable LDAP Search Filters
  • HTTP Basic Authentication
  • LDAP AuthenticationReference implementation, not production-hardened
  • LDAP STARTTLS Support

nginx-ldap-auth README

How to install nginx-ldap-auth

Install nginx-ldap-auth with Docker

Environment variables
PYTHON_VERSION

docker build -t nginx-ldap-auth-daemon . docker run nginx-ldap-auth-daemon

Use --build-arg PYTHON_VERSION=3 for Python 3

How to configure nginx-ldap-auth

  • --host0.0.0.0Host address for the ldap-auth daemon to listen on

    Host address for the ldap-auth daemon to listen on

    values: IP address or hostname

  • --port8888Port for the ldap-auth daemon to listen on

    Port for the ldap-auth daemon to listen on

    values: port number

  • X-CookieNamenginxauthCookie name for cookie-based authentication

    Cookie name for cookie-based authentication

    values: string

  • X-Ldap-BaseDNcn=Users,dc=test,dc=localBase DN for LDAP search

    Base DN for LDAP search

    values: LDAP DN

  • X-Ldap-BindDNcn=root,dc=test,dc=localBind DN for LDAP authentication

    Bind DN for LDAP authentication

    values: LDAP DN

  • X-Ldap-BindPasssecretBind password for LDAP authentication

    Bind password for LDAP authentication

    values: string

  • X-Ldap-RealmRestrictedRealm name for HTTP basic authentication

    Realm name for HTTP basic authentication

    values: string

  • X-Ldap-StarttlsNegotiate a TLS-enabled (STARTTLS) connection before sending credentials

    Negotiate a TLS-enabled (STARTTLS) connection before sending credentials

    values: true

  • X-Ldap-Template(cn=%(username)s)LDAP search filter template

    LDAP search filter template

    values: LDAP filter template

  • X-Ldap-URLldap://example.comURL and port for connecting to the LDAP server

    URL and port for connecting to the LDAP server

    values: ldap://host:port or ldaps://host:port

nginx-ldap-auth releases & version history

More in Identity & Auth

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…