`

nginx 访问密码校验

阅读更多

nginx 访问密码校验

nginx server配置

  1. server {
  2. listen 80;
  3. server_name 10.0.0.1;
  4. root /tmp;
  5. location / {
  6. add_header Cache-Control max-age=300;
  7. auth_basic "PASSWD";
  8. auth_basic_user_file htpasswd;
  9. }
  10. }


在配置文件当前目录下 建个htpasswd文件,内容格式如下,其中passwd需加密的

  1. user:passwd


passwd加密脚本,

  1. #!/usr/bin/perl
    use strict;
    my $pw=$ARGV[0];
    print crypt($pw,$pw)."\n";
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics