nignx文件服务器,添加用户认证
nginx搭建文件服务器,为了安全起见,但只想部分份能够下载。
Nginx进行用户名密码验证的话是通过ngx_http_auth_basic_module模块实现,该模块可作用范围http,server,location,limit_except,语法如下:
location / {
auth_basic "Please input your name";
auth_basic_user_file /etc/nginx/conf/htpasswd;
}
在conf目录下创建htpasswd文件,文件中添加用户名密码,格式如下
test:123456
重启nginx后,访问,效果如下: