用户认证
首先需要安装apache,可以使用yum install httpd 安装
生成密码文件,创建用户
htpasswd -c /usr/local/nginx/conf/htpasswd test // 添加test用户,第一次添加时需要加-c参数,第二次添加时不需要-c参数
在nginx的配置文件中添加 vi /usr/local/nginx/conf/vhosts/jzq.conf
location / {
root /data/www/uc_server;
auth_basic "Auth";
auth_basic_user_file /usr/local/nginx/conf/htpasswd;
}
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload
验证:
转载于:https://blog.51cto.com/68686789/1832154