nginx 访问密码校验

2331阅读 0评论2012-06-23 低头、真掩饰
分类:系统运维

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
  2. use strict;

  3. my $pw=$ARGV[0];
  4. print crypt($pw,$pw)."\n";

完成后,访问就需输入页面密码了


上一篇:nginx负载均衡302跳转 基于perl的一致性哈希
下一篇:hwclock 执行失败