elanbeat's wiki
LighttpdAuthentication

lighttpdの認証の設定方法


参考

設定

以下、認証タイプplainでBasic認証を行う場合について例示する。

ユーザ定義ファイルの作成

/etc/lighttpd/lighttpd.userを作成し、ユーザとパスワードを”:”で区切って記述する。


agent007:secret

ファイルのパーミッションを適切に設定する。


%chmode 600 /etc/lighttpd/lighttpd.user

lighttpd.confの編集

モジュールにmod_authを追加する。


server.modules              = ( ..., "mod_auth" )

mod_authの設定を追加する。


#### auth module
## read authentication.txt for more info
auth.debug                 = 0
auth.backend               = "plain" 
auth.backend.plain.userfile = "/etc/lighttpd/lighttpd.user" 
#auth.backend.plain.groupfile = "lighttpd.group" 

auth.require  = ( "/server-info" =>
                     (
                         "method"  => "basic",
                         "realm"   => "server information",
                         "require" => "user=agent07" 
                       )
                   )

再起動


#/etc/rc.d/init.d/lighttpd restart

テスト

http://hostname/server-infoに、user:agent07, password:secretでアクセスできることを確認する。