nginx 访问密码校验
nginx server配置
- server {
- listen 80;
- server_name 10.0.0.1;
- root /tmp;
- location / {
- add_header Cache-Control max-age=300;
- auth_basic "PASSWD";
- auth_basic_user_file htpasswd;
- }
- }
在配置文件当前目录下 建个htpasswd文件,内容格式如下,其中passwd需加密的
- user:passwd
passwd加密脚本,
- #!/usr/bin/perl
use strict;
my $pw=$ARGV[0];
print crypt($pw,$pw)."\n";