Created
April 28, 2015 02:48
-
-
Save hokuma/b4917224cbec154fc71f to your computer and use it in GitHub Desktop.
Basic認証対応apache(第3回勉強会課題)
This file contains hidden or 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
<Directory "/var/www/html/admin"> | |
AuthType Basic | |
AuthName "Input your id/password" | |
AuthUserFile "/.htpasswd" | |
Require valid-user | |
</Directory> |
This file contains hidden or 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
FROM centos:6 | |
MAINTAINER hokuma | |
RUN yum -y update && yum install -y httpd | |
ENV USERNAME admin | |
ENV PASSWORD qwerty | |
COPY server.conf auth.conf /etc/httpd/conf.d/ | |
COPY index.html /var/www/html/ | |
RUN mkdir /var/www/html/admin | |
RUN echo "CustomLog /proc/self/fd/1 combined" >> /etc/httpd/conf/httpd.conf | |
RUN echo "ErrorLog /proc/self/fd/2" >> /etc/httpd/conf/httpd.conf | |
COPY run.sh ./ | |
RUN chmod o+x ./run.sh | |
ENTRYPOINT ["./run.sh"] | |
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"] |
This file contains hidden or 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
#!/bin/bash | |
if [ "$1" = '/usr/sbin/httpd' ]; then | |
htpasswd -bc "/.htpasswd" $USERNAME $PASSWORD | |
fi | |
exec "$@" |
This file contains hidden or 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
ServerTokens Prod |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment