LoginSignup
1
1

More than 5 years have passed since last update.

[とあるコンテスト:Apache] Digest認証を設定してみる

Last updated at Posted at 2017-12-15

Hello World !!
今回は、CentOS上でhttp serverにDigest認証を実装させたいと思います。

※ Digest認証とは、Basic認証とは違い平文でパスワードを送信しない認証方式です。しかし、Basic認証よりもかなりセキュアであるという訳でもありませんので、一般的にはSSL(TSL)を使うべきです。

環境

  • Ubuntu 16.04 (on VirtualBox)
  • CentOS 7.4 (docker container)

設定内容

設定項目
認証対象のディレクトリ  /var/www/html/private
認証領域名        Private Zone
ユーザー管理ファイル   .htdigest
認証ユーザー       test

設定

# vi /etc/httpd/conf/httpd.conf          // 160行目辺りに、下記を書き込みます
<Directory "/var/www/html/private">
AuthType Digest
AuthName "Private Zone"
AuthUserFile /etc/httpd/.htdigest
Require user test
</Directory>
# mkdir /var/www/html/private
# vi /var/www/html/private/index.html    // 表示させるものを書き込む

# htdigest -c /etc/httpd/.htdigest 'Private Zone' test
Adding user test in realm Private Zone
New password: [任意のパスワード]
Re-type new password: [任意のパスワード]

# chown apache:apache /etc/httpd/.htdigest
# chmod 400 /etc/httpd/.htdigest

認証したいユーザーを追加したい場合は、

# vi /etc/httpd/conf/httpd.conf          // 160行目辺りに、下記を書き込みます
<Directory "/var/www/html/private">
(省略)
Require valid-user                       // or Require user test new_user
</Directory>

# htdigest /etc/httpd/.htdigest 'Private Zone' new_user
Adding user new_user in realm Private Zone
New password: [任意のパスワード]
Re-type new password: [任意のパスワード]

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1