Basic Authentication2015/12/03 |
Enable Basic Authentication to limit access on specific web pages.
|
|
[1] | For example, Configure Basic Authentication setting under the directory [/srv/www/htdocs/auth-basic]. |
www:~ # a2enmod auth_basic www:~ # mkdir /srv/www/htdocs/auth-basic
www:~ #
vi /etc/apache2/conf.d/auth-basic.conf # create new <Directory /srv/www/htdocs/auth-basic> AuthType Basic AuthName "Basic Authentication" AuthUserFile /etc/apache2/.htpasswd require valid-user </Directory> # add a user : create a new file with "-c" (add the "-c" option only for the initial regist) www:~ # htpasswd2 -c /etc/apache2/.htpasswd suse New password: # set password Re-type new password: Adding password for user suse
www:~ #
/etc/init.d/apache2 restart
# create a test page
www:~ #
vi /srv/www/htdocs/auth-basic/index.html <html> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> Test Page for Basic Auth </div> </body> </html> |
Access to the test page from a client computer with a web browser. Then authentication is required like follows as a setting, answer with a user added in [1]. |
Just accessed. |
Sponsored Link |
|