Welcome to FreeSoftwareServers Confluence Wiki

https://github.com/gabihodoroaga/nginx-ntlm-module

See here for config → NGinX - API Proxy - CORs - FreeSoftwareServers - FreeSoftwareServers

WD=/opt/nginx-ntlm
mkdir -p $WD/{setup,conf}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 nginx-ntlm:
    container_name: nginx-ntlm
    build: .
    hostname: nginx-ntlm
    ports:
      - '8545:80'
    volumes:
 #docker cp 26b547412ffb0beed134b88948e22c65179fb4011c165ad2c2d77c884a8f9751:/etc/nginx /opt/nginx-ntlm/conf/
 #     - type: bind
 #       read_only: true
 #       source: /opt/nginx-ntlm/conf/
 #       target: /etc/nginx

    environment:
      - 'TZ=${TZ}'

EOF
chmod +x docker-compose.yaml
cat <<'EOF'>Dockerfile
FROM alpine:3.13

ENV NGINX_VERSION 1.19.3


# install buidl tools
RUN set -x \
    && addgroup -g 101 -S nginx \
    && adduser -S -D -H -u 101 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \
    && apk add --no-cache --virtual .build-deps \
    gcc \
    libc-dev \
    make \
    openssl-dev \
    pcre-dev \
    zlib-dev \
    linux-headers \
    libxslt-dev \
    gd-dev \
    geoip-dev \
    perl-dev \
    libedit-dev \
    curl \
    git

WORKDIR /build 

# download nginx 
RUN curl -OL http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
    && tar -xvzf nginx-${NGINX_VERSION}.tar.gz && rm nginx-${NGINX_VERSION}.tar.gz \
    && git clone https://github.com/gabihodoroaga/nginx-ntlm-module.git

RUN cd nginx-${NGINX_VERSION}/ \
    && ./configure \
        --prefix=/etc/nginx \
        --sbin-path=/usr/sbin/nginx \
        --modules-path=/usr/lib/nginx/modules \
        --conf-path=/etc/nginx/nginx.conf \
        --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 \
        --with-perl_modules_path=/usr/lib/perl5/vendor_perl \
        --user=nginx \
        --group=nginx \
        --with-compat \
        --with-file-aio \ 
        --with-threads \
        --with-http_addition_module \
        --with-http_auth_request_module \
        --with-http_dav_module \
        --with-http_flv_module \
        --with-http_gunzip_module \
        --with-http_gzip_static_module \
        --with-http_mp4_module \
        --with-http_random_index_module \
        --with-http_realip_module \
        --with-http_secure_link_module \
        --with-http_slice_module \
        --with-http_ssl_module \
        --with-http_stub_status_module \
        --with-http_sub_module \
        --with-http_v2_module \
        --with-mail \
        --with-mail_ssl_module \
        --with-stream \
        --with-stream_realip_module \
        --with-stream_ssl_module \
        --with-stream_ssl_preread_module \
        --with-cc-opt='-Os -fomit-frame-pointer' \
        --with-ld-opt=-Wl,--as-needed \
        # add the ntlm module
        --add-module=../nginx-ntlm-module \
    && make \
    && make install \
    && mkdir -p /var/cache/nginx

WORKDIR /

# clean up 
RUN apk del .build-deps \
    && rm -rf /build \
    && apk add pcre

WORKDIR /etc/nginx/html

EXPOSE 80

STOPSIGNAL SIGQUIT

CMD ["nginx", "-g", "daemon off;"]
EOF
chmod +x Dockerfile
cd $WD/setup
cat << 'EOF'>.env
TZ=America/Whitehorse
EOF
chmod +x .env
WD=/opt/nginx-ntlm/setup
cat << EOF >$WD/nginx-ntlm.service.setup.sh
cat << EOL >/lib/systemd/system/nginx-ntlm.service
[Unit]
Description=nginx-ntlm_Docker
Requires=docker.service network-online.target

[Service]  

WorkingDirectory=$WD
ExecStartPre=docker-compose pull
Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name nginx-ntlm --project-directory $WD -f $WD/docker-compose.yaml up --force-recreate
ExecStop=/usr/bin/docker-compose --project-name nginx-ntlm --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable nginx-ntlm
systemctl restart nginx-ntlm
systemctl status nginx-ntlm
EOF
chmod +x $WD/nginx-ntlm.service.setup.sh
$WD/nginx-ntlm.service.setup.sh
  • No labels