Apache: Digest 認証の設定(Basic 認証じゃないよ)
忘れるのでメモ。
$ htdigest [ -c ] パスワードファイルパス レルム ユーザー名 // 例)1 ユーザー目(初めて認証ファイルを作るとき) // ユーザー名を demo-user、レルムを MEMBER ONLY で作成する $ htdigest -c /path/to/htdocs/.htdigest 'MEMBER ONLY' demo-user // 例)2 ユーザー目以降(2 回目以降) // ユーザー名を test-user、レルムを MEMBER ONLY で作成する # htdigest /path/to/htdocs/.htdigest 'MEMBER ONLY' test-user
次に .htaccess に上記コマンドで生成された .htdigest のパスや Digest 認証の設定を記述する。
AuthType Digest AuthName "MEMBER ONLY" AuthDigestDomain /path/to/domain/ AuthUserFile /path/to/.htdigest Require user demo-user test-user ※ Apache 2.2 未満は AuthUserFile ではなく AuthDigestFile に置き換える
Apache を再起動する。
$ sudo apachectl restart
Digest 認証をかけた URL にアクセスして確認する。
参考ページ
htdigest - manage user files for digest authentication - Apache HTTP Server
mod_auth_digest - Apache HTTP Server















