-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1574018
commit 384e3b2
Showing
8 changed files
with
132 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
* | ||
!docker-run.sh | ||
!rootfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
FROM debian:10-slim as build | ||
ARG FROM=debian:10-slim | ||
|
||
FROM $FROM as build | ||
|
||
ENV PACKAGES="apache2" | ||
|
||
# Install apache | ||
RUN apt-get update \ | ||
&& apt-get -y install dumb-init apache2 | ||
&& apt-get -y install $PACKAGES | ||
|
||
# Add Fancy Index | ||
ADD https://github.com/Vestride/fancy-index/archive/master.tar.gz /usr/share/ | ||
RUN tar xzf /usr/share/master.tar.gz -C /usr/share | ||
# Copy root filesystem | ||
COPY rootfs / | ||
|
||
# Configure apache | ||
RUN echo 'ServerSignature Off' >> /etc/apache2/apache2.conf \ | ||
&& echo 'TraceEnable Off' >> /etc/apache2/apache2.conf \ | ||
&& echo 'ServerTokens Prod' >> /etc/apache2/apache2.conf \ | ||
&& echo 'ServerName docker-http' >> /etc/apache2/apache2.conf \ | ||
&& echo 'Alias /fancy-index /usr/share/fancy-index-master' >> /etc/apache2/apache2.conf \ | ||
&& echo '<Directory /var/www/html>' >> /etc/apache2/apache2.conf \ | ||
&& cat /usr/share/fancy-index-master/.htaccess >> /etc/apache2/apache2.conf | ||
RUN a2enconf z-custom-config.conf \ | ||
&& a2enmod auth_digest | ||
|
||
# Add auth handler | ||
COPY docker-run.sh / | ||
# Add/Configure Fancy Index | ||
ADD https://github.com/Vestride/fancy-index/archive/master.tar.gz /usr/share/ | ||
RUN tar xzf /usr/share/master.tar.gz -C /usr/share \ | ||
&& echo 'Alias /fancy-index /usr/share/fancy-index-master' >> /etc/apache2/apache2.conf \ | ||
&& echo '<Directory /html>' >> /etc/apache2/apache2.conf \ | ||
&& cat /usr/share/fancy-index-master/.htaccess >> /etc/apache2/apache2.conf \ | ||
&& echo '</Directory>' >> /etc/apache2/apache2.conf | ||
|
||
# Final image | ||
# Build final image | ||
RUN apt-get -y install dumb-init \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
FROM scratch | ||
COPY --from=build / / | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--"] | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["/docker-run.sh"] | ||
CMD ["/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
USER=casperklein | ||
NAME=http | ||
TAG=latest | ||
|
||
[ -n "$USER" ] && TAG=$USER/$NAME:$TAG || TAG=$NAME:$TAG | ||
|
||
DIR=$(dirname "$(readlink -f "$0")") && | ||
cd "$DIR" && | ||
echo "Building: $TAG" && | ||
echo && | ||
docker build -t $TAG . |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ServerName docker-http | ||
|
||
# Security settings | ||
ServerSignature Off | ||
TraceEnable Off | ||
ServerTokens Prod | ||
|
||
# Logging | ||
LogFormat "%t [%V:%p] %h %u \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" detailed | ||
LogFormat "%t [%V:%p] %{X-Forwarded-For}i,%h %u \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" proxy | ||
|
||
<Directory /html> | ||
Options +FollowSymLinks | ||
AllowOverride None | ||
Require all granted | ||
</Directory> | ||
|
||
# Authentication template | ||
<Directory /marker> | ||
Options +FollowSymLinks | ||
AllowOverride None | ||
|
||
AuthType Digest | ||
AuthName "This is a private system. Do not attempt to login unless you are an authorized user." | ||
AuthDigestProvider file | ||
AuthUserFile /.htdigest | ||
Require valid-user | ||
</Directory> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | ||
DocumentRoot /html | ||
|
||
ErrorLog ${APACHE_LOG_DIR}/error.log | ||
|
||
# Log correct client IP if request comes from a reverse proxy | ||
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded | ||
CustomLog ${APACHE_LOG_DIR}/access.log detailed env=!forwarded | ||
CustomLog ${APACHE_LOG_DIR}/access.log proxy env=forwarded | ||
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -d "/html" ]; then | ||
echo -e "Error: No host directory mounted to /html\n" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo -ne "HTTP-Auth:\t" | ||
|
||
# check if $user/$pass is supplied | ||
if [ -n "$user" ] && [ -n "$pass" ] || [ -n "$auth" ]; then | ||
# enable auth | ||
sed -i 's;<Directory /html>;<Directory /foo>;' /etc/apache2/conf-available/z-custom-config.conf | ||
sed -i 's;<Directory /marker>;<Directory /html>;' /etc/apache2/conf-available/z-custom-config.conf | ||
echo "enabled" | ||
|
||
# generate user/pass if $auth is supplied | ||
if [ -n "$auth" ]; then | ||
user=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 10) | ||
pass=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 10) | ||
fi | ||
|
||
echo -e "Username:\t$user" | ||
echo -e "Password:\t$pass" | ||
|
||
# generate .htdigest file | ||
DIGEST="$(printf "%s:%s:%s" "$user" "This is a private system. Do not attempt to login unless you are an authorized user." "$pass" | md5sum | awk '{print $1}')" && | ||
printf "%s:%s:%s\n" "$user" "This is a private system. Do not attempt to login unless you are an authorized user." "$DIGEST" > /.htdigest || exit 1 | ||
else | ||
echo "disabled" | ||
fi | ||
|
||
echo | ||
|
||
# Start apache2 | ||
apachectl start && | ||
|
||
# Show logs | ||
tail -F /var/log/apache2/* |