Nginx中设置密码保护

location ^~ /www/ {
	auth_basic "Message for password";
	auth_basic_user_file /root/password;
}

然后/root/password中的格式为,用户名:密码,如下:

minamoto:shedNjPenV9SI

不过后面的密码,需要crypt进行加密,可以用如下的脚本加密:

#!/usr/bin/perl
use strict;
my $pw=$ARGV[0];
print crypt($pw,$pw)."\n";

 

1 thought on “Nginx中设置密码保护

Leave a Reply

Your email address will not be published.