一:nginx状态查看
--with-http_stub_status_module记录NGINX客户端基本访问状态
Syntax:stub_status;
Default: -
Context: server,location
用法:
location /suibianxie {
stub_status on;
}
访问IP/suibianxie
Active connections: 2 //nginx当前活跃连接数 server accepts handled requests 5 5 13 Reading: 0 Writing: 1 Waiting: 1
server表示NGINX启动到现在共处理了5个请求
accepts表示NGINX启动到现在共成功创建5次握手
请求丢失数=(握手数-连接数)可以看出,本次状态显示没有丢失
handled requests 表示总共处理了13次请求
reading NGINX读取到客户端的header信息数
writing NGINX返回给客户端的header信息数
waiting NGINX开启keep-alive长连接情况下,既没有读也没有写
二:nginx下载站点
Syntax: autoindex on | off;
Default:
autoindex off;
Context: http, server, location
autoindex常用参数
autoindex_exact_size off;
on, 显示出文件的确切大小,单位为bytes.。
off, 显示出文件的大概大小,单位是KB或者MB或者GB
autoindex_localtime on;
off,显示的文件时间为GMT时间。
on,现实的文件时间为文件的服务器时间。
charset utf-8,gpk; //乱码的话,解决乱码问题
配置文件如下:
location /download {
root /usr/share/nginx/html;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
访问ip/download
另外两种方法
### 开启二级目录
location /download {
root /usr/share/nginx/html/download;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
### 别名的方式
location /down {
root /usr/share/nginx/html/download;
autoindex on;
autoindex_localtime on;
autoindex_exact_size off;
}
三:防盗链
valid_referers none blocked 本机IP或域名;
if ($invalid_referers){
return 403;
}