Ubuntu 19.04
Sponsored Link

Apache2 : Basic Authentication + PAM2019/04/26

 
Limit accesses on specific web pages and use OS users for authentication with SSL connection.
[1]
[2] For example, set Basic Authentication under the [/var/www/html/auth-pam] directory.
root@www:~#
apt -y install libapache2-mod-authnz-external pwauth
root@www:~#
vi /etc/apache2/sites-available/auth-pam.conf
# create new

AddExternalAuth pwauth /usr/sbin/pwauth
SetExternalAuthMethod pwauth pipe
<Directory /var/www/html/auth-pam>
    SSLRequireSSL
    AuthType Basic
    AuthName "PAM Authentication"
    AuthBasicProvider external
    AuthExternal pwauth
    require valid-user
</Directory>

root@www:~#
mkdir /var/www/html/auth-pam

root@www:~#
a2ensite auth-pam

Enabling site auth-pam.
To activate the new configuration, you need to run:
  service apache2 reload
root@www:~#
systemctl restart apache2
# create a test page

root@www:~#
vi /var/www/html/auth-pam/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for PAM Auth
</div>
</body>
</html>
[3] Access to the test page with a Web browser on Client Computer and authenticate with a user which is on OS.
[4] Just accessed.
Matched Content