Ubuntu 24.04
Sponsored Link

Apache2 : Basic Authentication + PAM2024/05/17


Limit accesses on specific web pages and use OS users for authentication with SSL connection.


Configure SSL/TLS Setting, refer to here.

[2] For example, set Basic Authentication under the [/var/www/html/auth-pam] directory.
apt -y install libapache2-mod-authnz-external pwauth
vi /etc/apache2/sites-available/auth-pam.conf
# create new

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

mkdir /var/www/html/auth-pam

a2ensite auth-pam

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

vi /var/www/html/auth-pam/index.html
<p style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page for PAM Auth
[3] Access to the test page with a Web browser on any Client Computer, then authentication is required for settings. Authenticate with an existing OS user.
[4] That's OK if authentication passed and test page is shown normally.
Matched Content