nginx add access control to directory

Modify the main configuration file

vim /usr/local/nginx/conf/nginx.conf

Add the following in the configuration file

location / any directory (for example: ADMIN) {
stub_status ON;
access_log OFF;
}

Check grammar errors

nginx -t
reload the configuration items
killall -HUP nginx

But now is not safe, we need to do some limitations

 yum -y install httpd-tools

 

First need to create -c, then do not, because if you have only one user has been -c, it will refresh reconstruction

-c /usr/local/nginx/conf/.user LTY htpasswd
New password: (password)
Re-new new of the type password: (Enter password again)
Adding password for the User xxxx (password change prompt success)

basic: an authentication method, in fact, there are two authentication methods: Basic (standard) certification, digest authentication

Modify the main configuration file

 vim /usr/local/nginx/conf/nginx.conf

Add Content:

auth_basic "Nginx Status";
auth_basic_user_file /usr/local/nginx/conf/.user;

Login authentication is required when other users access

Guess you like

Origin www.cnblogs.com/990114-jhc/p/11543708.html