# Nginx 基础认证
location /admin {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
# Apache 基础认证
<Directory "/var/www/admin">
AuthType Basic
AuthName "Restricted"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
htpasswd 文件用于 Nginx/Apache 的 HTTP 基础认证 (Basic Auth)。Bcrypt 是最安全的算法,推荐在生产环境使用。生成后将内容保存到 .htpasswd 文件中。
⚠️\x20浏览器端不支持真正的\x20Bcrypt。如需\x20Bcrypt,请使用\x20htpasswd\x20命令行工具:htpasswd\x20-B\x20.htpasswd\x20'+a+'
'+''+h+''+''+'';}function downloadHtpasswd(b){var c=new Blob([b],{'type':'text/plain'}),d=document['createElement']('a');d['href']=URL['createObjectURL'](c),d['download']='.htpasswd',d['click']();}function copyText(a){if(navigator['clipboard'])navigator['clipboard']['writeText'](a);else{var b=document['createElement']('textarea');b['value']=a,document['body']['appendChild'](b),b['select'](),document['execCommand']('copy'),document['body']['removeChild'](b);}}