ベスパリブ

プログラミングを主とした日記・備忘録です。ベスパ持ってないです。

Raspbian, Apache2でダイジェスト認証

Raspbian 8.0
Apache 2.4.10(Raspbian)

ダイジェスト認証に必要なモジュールを有効化する

$ sudo a2enmod auth_digest
$ sudo a2enmod authn_file
$ sudo a2enmod authz_user

Apache2の設定をする

$ sudo vi /etc/apache2/apache2.conf

(以下を適当なところに追加)

# Digest Authentication

<Directory /myproject/www/>

        AuthType Digest

        AuthName "DigestZone"

        AuthUserFile /myproject/www/.htdigest

        Require valid-user

</Directory>

ダイジェスト認証のファイルを作成する

$ sudo htdigest -c /myproject/www/.htdigest "DigestZone" root

Adding password for root in realm DigestZone.

New password:root

Re-type new password:root

Apache2の再起動

$ sudo service apache2 restart
$ sudo systemctl daemon-reload