From c552d3a12bc4a042cbf67b0b409a014fa1fb08a2 Mon Sep 17 00:00:00 2001 From: Artem Stepanov Date: Tue, 5 Jul 2016 16:21:23 +0300 Subject: [PATCH 1/2] Added ctl script for RedHat linux. --- nginx-ldap-auth-daemon-ctl-rh.sh | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 nginx-ldap-auth-daemon-ctl-rh.sh diff --git a/nginx-ldap-auth-daemon-ctl-rh.sh b/nginx-ldap-auth-daemon-ctl-rh.sh new file mode 100755 index 0000000..af647ac --- /dev/null +++ b/nginx-ldap-auth-daemon-ctl-rh.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +CMD=nginx-ldap-auth-daemon.py +if [ ! -f "$CMD" ]; then + echo "Please run '$0' from the same directory where '$CMD' file resides" + exit 1 +fi + +CMD=$PWD/$CMD +PIDFILE=./nginx-ldap-auth-daemon.pid + +. /etc/init.d/functions + +start() { + echo -n "Starting ldap-auth-daemon: " + if [ -s ${PIDFILE} ]; then + RETVAL=1 + echo -n "Already running !" && warning + echo + else + nohup ${CMD} >/dev/null 2>&1 & + RETVAL=$? + PID=$! + [ $RETVAL -eq 0 ] && success || failure + echo + echo $PID > ${PIDFILE} + fi +} + +case $1 in + "start") + start + ;; + "stop") + echo -n "Stopping ldap-auth-daemon: " + killproc -p $PIDFILE $CMD + echo + ;; + *) + echo "Usage: $0 " + ;; +esac From 2c850795e98998ac08ea230fb41c8c6aeeacf68d Mon Sep 17 00:00:00 2001 From: Oleksandr Moskalenko Date: Wed, 27 Jul 2016 11:20:33 +0200 Subject: [PATCH 2/2] Changes allowing to create Docker image for ldap auth daemon --- Dockerfile | 18 ++++++++++++++++++ README.md | 14 ++++++++++++++ requirements.txt | 1 + 3 files changed, 33 insertions(+) create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7b23cd0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:2-alpine + +COPY requirements.txt /usr/src/app/ +COPY nginx-ldap-auth-daemon.py /usr/src/app/ + +WORKDIR /usr/src/app/ + +# Install required software +RUN \ + apk --no-cache add openldap-dev && \ + apk --no-cache add --virtual build-dependencies build-base && \ + pip install -r requirements.txt && \ + apk del build-dependencies + + +EXPOSE 8888 + +CMD ["python", "/usr/src/app/nginx-ldap-auth-daemon.py"] diff --git a/README.md b/README.md index d176cf0..a25f501 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,20 @@ To install and configure the reference implementation, perform the following ste 1. To test the reference implementation, use a web browser to access **http://*nginx-server-address*:8081**. Verify that the browser presents a login form. After you fill out the form and submit it, verify that the server returns the expected response to valid credentials. The sample back-end daemon returns this:
Hello, world! Requested URL: URL
+ +### Run as Docker container + +Another option to run authentication daemon is [Docker](https://www.docker.com/what-docker) + +1. [Install and run Docker daemon](https://docs.docker.com/engine/getstarted/) + +2. Run following commands to start the ldap-auth daemon in Docker container +
# docker build -t nginx-ldap-auth .
+# docker run --name=nginx-ldap-auth --restart=always -d -p 8888:8888 nginx-ldap-auth
+ +3. Modify the NGINX Plus configuration file as described in [Required Modifications to the NGINX Plus Configuration File](#required-mods) below. +
+ ### Required Modifications to the NGINX Plus Configuration File diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..04f438d --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +python-ldap