auth_basic+autoindex模块+ upload 参数

ngx_http_auth_basic_module模块:实现基于用户的访问控制,使用basic机制进行用户认证,
auth_basic string | off;
auth_basic_user_file file;
location /admin {
auth_basic "Admin Area";
auth_basic_user_file /etc/nginx/.ngxpasswd; }
用户口令文件:
1、明文文本:格式name:password:comment
2、加密文本:由htpasswd命令实现(httpd-tools所提供)
yum install httpd-tools -y
htpasswd -cbm /apps/nginx/conf/.htpasswd zjol 123456
htpasswd -bm /apps/nginx/conf/.htpasswd zzhz 123456

 

server {
        listen       80;
        server_name  login.zjol.com.cn;
        charset utf-8;

        location /login/{
            root   /data/nginx/html/;
            index  index.html index.htm;
            auth_basic "login password";
            auth_basic_user_file /usr/local/nginx/conf/.htpasswd;

           allow  192.168.80.1;
           deny all;

        }
}

 测试  curl -u zzhz:123456 www.abc.com/admin

-------------------------------------------------------------------------------------------------------------

ngx_http_autoindex_module 配置文件下载服务
autoindex on | off; 自动文件索引功能,默为off
autoindex_exact_size on | off; 计算文件确切大小(单位bytes),off 显示大概大小(单位K、M),默认on
autoindex_localtime on | off ; 显示本机时间而非GMT(格林威治)时间,默认off
autoindex_format html | xml | json | jsonp;显示索引的页面文件风格,默认html
limit_rate speed; 限制客户端每秒钟传输的字节数;默认为0,表示没有限制

 


-------------------------------------------------------------------------------------------------------------

nginx-upload-module  配置文件上传模块参数,需要代码支持或第三方模块 --add-module=/path/nginx-upload-module。wget https://codeload.github.com/vkholodkov/nginx-upload-module/zip/2.2

curl -XPUT /etc/issue http://www.magedu.net/upload

#部分参数
client_max_body_size 10m;
client_body_buffer_size 16k;
client_body_temp_path /apps/nginx/temp 1 2 2;

-------------------------------------------------------------------------------------------------------------

实例:

server {
        listen       80;
        server_name  download.zjol.com.cn;
        charset GB2312;

        location /download {
                root   /data/nginx/html/;
                default_type text/html;
                autoindex on;
                autoindex_exact_size on;
                autoindex_localtime on;
                limit_rate 100k;
        }
       location /upload {
                root /data/nginx/html;

                client_max_body_size 10m;
                client_body_buffer_size 16k;
                client_body_temp_path  /usr/local/nginx/  1 2 2;


        }


}

 

posted @ 2022-07-17 11:34  yuanbangchen  阅读(47)  评论(0编辑  收藏  举报