Amazon Linux に Apache 環境でBasic認証をかけてみた。
ここでは、ユーザー名:user1、パスワード:pass で認証設定をする。
htpasswd -c -b /etc/httpd/conf/.htpasswd user1 pass
httpd.conf にBASIC認証の設定を追加する。
vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/">
AuthUserFile /etc/httpd/conf/.htpasswd
AuthGroupFile /dev/null
AuthName "Basic Auth"
AuthType Basic
Require valid-user
</Directory>
Apacheを再起動する。
/etc/init.d/httpd restart