Skip to content

Commit

Permalink
First commit with working nginx docker image with ldap module embeded.
Browse files Browse the repository at this point in the history
Also first try with Github action (not working but needed "unlock" actions inteface)
  • Loading branch information
NokiDev committed Feb 1, 2021
1 parent 545cce9 commit 720f4b9
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/publish_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Publish docker image
on:
- push
jobs:
build_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: docker-compose build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vs
.vscode
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# docker_nginx-ldap

NGINX with LDAP support docker image.
This image was highly inspired from : https://github.com/hrak/nginx-ldap

I just wanted to upload something for the community since nginx with ldap support seems to have disappear.
This time I'll upload the images via Github ghcr.io.



I'll try to follow and update this image but don't hesitate to fork this repo if I'm not fast enough to handle your request.

If you want to Contribute, either by making a PR or creating an issue, feel free to do so.


53 changes: 53 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG alpine_version=3.10
FROM alpine:$alpine_version as nginx-build
ARG nginx_version=release-1.16.1

RUN echo "==> Installing dependencies..." \
&& apk update \
&& apk add --virtual build-deps \
make gcc libc-dev openldap-dev \
pcre-dev libressl-dev zlib-dev \
linux-headers wget git

WORKDIR /build
RUN git clone https://github.com/kvspb/nginx-auth-ldap.git && git clone https://github.com/nginx/nginx.git

COPY ./build.sh /build/build.sh

RUN chmod 700 /build/build.sh && /build/build.sh $nginx_version

FROM alpine:$alpine_version as nginx-run

ARG dockerize_version=v0.6.1

COPY --from=nginx-build "/usr/local/nginx/" "/usr/local/nginx/"
COPY --from=nginx-build "/etc/nginx/" "/etc/nginx/"

RUN echo "==> Configuring system" \
&& addgroup -S nginx \
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
&& mkdir /etc/nginx/conf.d \
&& rm -f /etc/nginx/*.default \
&& mkdir /var/log/nginx \
&& touch /var/log/nginx/access.log /var/log/nginx/error.log \
&& mkdir -p /usr/share/nginx/html \
&& install -m644 /usr/local/nginx/html/index.html /usr/share/nginx/html/ \
&& install -m644 /usr/local/nginx/html/50x.html /usr/share/nginx/html/ \
&& ln -sf /usr/local/nginx/sbin/nginx /usr/sbin/nginx \
&& apk update \
&& apk add --no-cache \
libpcrecpp libpcre16 libpcre32 libressl libssl1.1 pcre libldap libgcc libstdc++ \
&& rm -rf /var/cache/apk/* \
&& wget -O /tmp/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$dockerize_version/dockerize-alpine-linux-amd64-$dockerize_version.tar.gz \
&& tar -C /usr/local/bin -xzvf /tmp/dockerize.tar.gz \
&& rm -rf /tmp/dockerize.tar.gz

COPY nginx.default.conf /etc/nginx/nginx.conf
COPY nginx.vh.default.conf /etc/nginx/conf.d/default.config

WORKDIR /usr/local/nginx

EXPOSE 80 443

COPY run.sh /run.sh
CMD ["/run.sh"]
39 changes: 39 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

NGINX_VERSION=$1

mkdir -p /var/log/nginx && mkdir -p /etc/nginx
cd nginx
echo "Building $NGINX_VERSION"
git checkout tags/${NGINX_VERSION}

./auto/configure \
--add-module=/build/nginx-auth-ldap \
--with-http_ssl_module \
--with-debug \
--conf-path=/etc/nginx/nginx.conf \
#--sbin-path=/usr/sbin/nginx \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-stream \
--with-stream_ssl_module \
--with-debug \
--with-file-aio \
--with-threads \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_v2_module \
--with-http_auth_request_module \

echo "==> Building Nginx..."
make -j$(getconf _NPROCESSORS_ONLN)
make install
31 changes: 31 additions & 0 deletions build/nginx.default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}
44 changes: 44 additions & 0 deletions build/nginx.vh.default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
6 changes: 6 additions & 0 deletions build/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e
if test -e /nginx.conf; then
cp -v /nginx.conf /etc/nginx/nginx.conf
fi
exec dockerize -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.3'

services:
nginx_build:
build:
context: ./build
image: ghcr.io/NokiDev/nginx-ldap:release-1.16.1

0 comments on commit 720f4b9

Please sign in to comment.