Basic認証の設定方法

何度もやっているのだが、たまにしか行わないために覚え書き。

まずは、httpd設定ファイルへの設定。
http://xxx.xxx.xxx/hoge へアクセスする場合の設定となる。

[bash]
$ mv /etc/httpd/conf.d/
$ vi hoge.conf

<Location /hoge>
AuthType Basic
AuthName "Whoocus"
AuthUserFile /etc/httpd/auth_file/.hoge_passwd_file # パスワードファイルの場所
Require valid-user
</Location>

[/bash]

そして、パスワードファイルの作成
新規にパスワードファイルを作成する場合は -c オプションを付加する。
[bash]
$ htpasswd -c /etc/httpd/auth_file/.hoge_passwd_file whoocus
New password: *****
Re-type new password: *****
[/bash]

Webサーバの再起動。
[bash]
$ /etc/rc.d/init.d/httpd restart
[/bash]

これでBasic認証の設定完了。

This entry was posted in CentOS, 技術情報. Bookmark the permalink.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です