There are two general commands for generating password files in Linux
Opensslpasswd-crypt passwd will generate a string after the file does not need
The other is
Htpasswd-c/etc/filename.db username
The user name is displayed in the password:
When the system shows that there is no htpasswd command, you can display the installed software after the input htpasswd (Ubuntu)
Finally post the configuration of my own nginx as a reference:
server {
Listen 9200;
server_name xxxxxxxx;
CharSet UTF8;
Auth_basic "Secret"; # #使用openssl Passwd-crypt Passwds The location of the configuration when encrypting
Auth_basic_user_file/etc/nginx/passwords; # #可以不需要文件后缀
Location/{
Proxy_pass http://xxxxxxxxxx;
Proxy_redirect default;
Proxy_connect_timeout 60;
Proxy_send_timeout 172800;
Proxy_read_timeout 6000;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Proxy_buffering off;
Auth_basic "Secret"; # #使用htpasswd加密的时候配置的位置
auth_basic_user_file/etc/nginx/passwords.db;
Proxy_max_temp_file_size 0;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html;
}
}
This article from "East God to a dozen five" blog, declined reprint!
Two types of Nginx configuration user rights access