Apache2 : Basic Authentication + PAM2024/05/17 |
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> 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 reload apache2
# create a test page
root@www:~#
vi /var/www/html/auth-pam/index.html <html> <body> <p style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> Test Page for PAM Auth </p> </body> </html> |
[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. |
Sponsored Link |
|