2007年4月24日 星期二

My first try in the password authentication for Apache2

I have installed a webcam to my Ubuntu box, Ubuntu use the "webcam" program can transfer the image picture to somewhere under directory /var/www/.
But it is not safe because anyone can browse the content under /var/www by typing
http://ip_address
Nix told me that I can setup the Apache to make the password prompt!
The following is my steps under Unbutu feisty, where the Apache version 2.2.3-4

1. Basic Authentiation
# vi /etc/apache2/apache2.conf
add the following block
-----------------------------------
<Directory /var/www>
AuthType Basic
AuthName "Restricted Files"
AuthBasicProvider file
AuthUserFile /etc/apache2/web_password
Required user the_user
</Directory>

-------------------------------------
then
# htpasswd -c web_password the_user
# apache2ctl restart
to create the password


But the basic method transfer the password by the plain text, I try the second method

2. Digest Authentication
Add the following block in /etc/apache2/apache2.conf
---------------------------------------------
<Location "/">
AuthType Digest
AuthName "Private"
AuthDigestDomain "/" http://ip_address
AuthDigestFile /etc/apache2/webdigest
Require valid-user
</Location>
--------------------------------------
Check if the auth_digest.load exists in /etc/apache2/mods-enabled
# ls /etc/apache2/mods-enabled
if no, create a symbolic link
# ln -s /etc/apache2/mods-available/auth_digest.load /etc/apache2/mods-enabled/auth_digest.load

Create the digest password:
# htdigest -c webdigest Private username

I am not sure the meaning of Private, it seems have to be the same as the one specified in AuthName in apache2.conf.
And the meaining of Location still needs investigation!

沒有留言:

佇 Linux 來看GPX 檔案

最近定定有戶外活動。使用𤆬路機 (GPS) 來記錄行過的路線。普通我記錄路線,攏是用手機仔抑是專門个𤆬路機,罕得用電腦來看。 毋過,"仙人拍鼓有時錯,跤步踏差啥人無"。有一擺我無細膩,袂記得共一擺活動的路線收煞起來,閣直接開始記錄下一擺的活動,按呢共幾落...