需要对后台地址admin进行保护,
http://www.abc/admin/admin.action之类的
可以使用http auth basic,既方便又简单,
1、首先要利用用apache 的 htpasswd 可以生成密码文件
只好先安装apache了
wget http://xxxx/tools/apache-2.0.63.tar.bz2
解压之后
./configure --prefix=/home/app/httpd-2.0.63
make && make install
创建用户和账号:
/home/app/httpd-2.0.63/bin/htpasswd -c -d /home/nginx/conf/pass_file username
然后需要输入要密码
再次确认数据即可生效了。
1.生成指定登录密钥
“cd /usr/local/nginx/conf
mkdir auth
cd auth/
htpasswd -c -d .htpasswd 用户名 #回车并输入密码再回车
2.编conf配置
代码可以放在 http, server, location, limit_except 段
“auth_basic “Restricted”;
auth_basic_user_file auth/.htpasswd;
3.重启nginx
“/usr/local/nginx/sbin/nginx -s reload
注意 nginx 0.6.7 开始,auth_basic_user_file 的相对目录是 nginx_home/conf,以前版本的相对目录是 nginx_home。
[nginx添加http header]nginx添加http auth basic认证实现方法
http://m.bbyears.com/jiaocheng/36763.html
推荐访问: