nginx 认证 下载加密 wget如何下载

1.  nginx配置如下

##########################################################################

server {
listen 9003 default_server;
#listen [::]:9003 default_server;
server_name _;
root /data/static;
autoindex on; #开启索引功能
autoindex_exact_size off; # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)
autoindex_localtime on; # 显示本机时间而非 GMT 时间
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

auth_basic "username"; #虚拟主机认证命名
auth_basic_user_file /data/nginx/passwd.db; #虚拟主机用户名密码认证数据库

location / {
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

##########################################################################

 

2. 生成 /data/nginx/passwd.db

  安装httpd  yum install httpd

  htpasswd -c /usr/local/nginx/passwd.db username  //创建认证信息

  New password: *******  //输入认证密

  Re-type new password: ********  //再次输入认证密

  Adding password for user xiaonuo

  chmod 400 /usr/local/nginx/passwd.db

 

3. wget 如何下载需要密码访问的链接

   wget --http-user username --http-passwd pwd http://163py.com:9003/readme.txt


分享到: 微信 更多