SLES 15
Sponsored Link

Apache2 : Basic Authentication2019/01/25

 
Enable Basic Authentication to limit access on specific web pages.
[1] For example, set 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" ("-c" is needed 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:~ #
systemctl restart apache2
# 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.
Matched Content