FROM nginx:latest
# author
MAINTAINER kevin
WORKDIR /myapp
COPY ./ ./
RUN rm -rf /etc/nginx/conf.d/default.conf
ADD default.conf /etc/nginx/conf.d
RUN echo "now building..."
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Nginx default configuration file
/etc/nginx/conf.default.conf
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
auth_basic "Restricted"; # A message which will be represented when it is authenticated
auth_basic_user_file /etc/nginx/.htpasswd; # File path for.htpasswd
}
}