nginxでBasic認証
nginxでBasic認証をかける時のメモ
1. Basic認証用のユーザー・パスワードを設定
# yum install httpd-tools
# cd /etc/nginx/ # htpasswd -c .htpasswd username New password: Re-type new password:
2. Basic認証を有効化
/etc/nginx/conf.d/app.conf
server { listen 80; server_name example.com; root /path/to/public; location / { auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; } }