Skip to content

Instantly share code, notes, and snippets.

@hokuma
Created April 28, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokuma/b4917224cbec154fc71f to your computer and use it in GitHub Desktop.
Save hokuma/b4917224cbec154fc71f to your computer and use it in GitHub Desktop.
Basic認証対応apache(第3回勉強会課題)
<Directory "/var/www/html/admin">
AuthType Basic
AuthName "Input your id/password"
AuthUserFile "/.htpasswd"
Require valid-user
</Directory>
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"]
#!/bin/bash
if [ "$1" = '/usr/sbin/httpd' ]; then
htpasswd -bc "/.htpasswd" $USERNAME $PASSWORD
fi
exec "$@"
ServerTokens Prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment