mirror of
https://github.com/hoellen/dockerfiles.git
synced 2025-04-19 20:09:16 +00:00
reverse: re-add ngxpasswd
This commit is contained in:
parent
287b32d56e
commit
24868449c2
@ -29,6 +29,7 @@ RUN echo "@commuedge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/ap
|
||||
libgcc \
|
||||
libstdc++ \
|
||||
su-exec \
|
||||
openssl \
|
||||
tini@commuedge \
|
||||
&& cd /tmp && git clone https://github.com/bagder/libbrotli && cd libbrotli \
|
||||
&& ./autogen.sh && ./configure && make -j $NB_CORES && make install \
|
||||
@ -82,6 +83,7 @@ RUN echo "@commuedge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/ap
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf/nginx.conf
|
||||
COPY run.sh /usr/local/bin/run.sh
|
||||
COPY ngxpasswd /usr/local/bin/ngxpasswd
|
||||
|
||||
RUN chmod +x /usr/local/bin/*
|
||||
|
||||
|
42
reverse/ngxpasswd
Normal file
42
reverse/ngxpasswd
Normal file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
NAME="$1"
|
||||
USER="$2"
|
||||
PASSWORD="$3"
|
||||
|
||||
cd /passwds || exit 1
|
||||
|
||||
if [ -z "$NAME" ]; then
|
||||
echo "Service name must be defined" 1>&2
|
||||
exit 1
|
||||
elif [ -f $NAME.htpasswd ]; then
|
||||
echo "$NAME.htpasswd exists, aborting" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$USER" ]; then
|
||||
echo "User must be defined" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$PASSWORD" ]; then
|
||||
PASSWORD=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1`
|
||||
echo "Password was not defined, generating a random one..."
|
||||
fi
|
||||
|
||||
echo -n $USER:`openssl passwd -apr1 $PASSWORD` >> $NAME.htpasswd
|
||||
chown $UID:$GID $NAME.htpasswd
|
||||
chmod 640 $NAME.htpasswd
|
||||
|
||||
echo
|
||||
echo "A new password file has been saved to /passwds/$NAME.htpasswd :"
|
||||
echo "- Service : $NAME"
|
||||
echo "- User : $USER"
|
||||
echo "- Password : $PASSWORD"
|
||||
echo
|
||||
echo "Paste this to your vhost in order to enable auth :"
|
||||
echo " auth_basic \"Who's this?\";"
|
||||
echo " auth_basic_user_file /passwds/$NAME.htpasswd;"
|
||||
echo
|
||||
echo "Done."
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user