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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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; } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构