Nginx : Configure Basic Auth2019/08/07 |
|
Enable Basic Authentication to restrict access on specific web pages.
|
|
| [1] | For example, set Basic Auth under the [/auth-basic] directory. |
|
root@www:~#
apt -y install apache2-utils
root@www:~#
vi /etc/nginx/sites-available/default # add into the [server] section
location /auth-basic/ {
auth_basic "Basic Auth";
auth_basic_user_file "/etc/nginx/.htpasswd";
}
# add user for Basic authentication root@www:~# htpasswd -c /etc/nginx/.htpasswd debian New password: # set password Re-type new password: Adding password for user debian |
| [2] | Access to the test page with Web browser from any Client and authenticate with a user which is added with htpasswd. |
|
| [3] | Just accessed. |
|
| Sponsored Link |
|
|