- https://github.com/railwayapp-templates/nginx をもとにして作成
htpasswd -c .htpasswd user
実行して認証用ファイル生成する- Dockerfile をこんな感じに更新して
FROM nginx:alpine
COPY .htpasswd /etc/nginx/.htpasswd
COPY nginx.conf /etc/nginx/nginx.conf
COPY site /usr/share/nginx/html
- nginx.confはこんな感じに更新
events {}
http {
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
auth_basic "認証が必要です";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
}