nginx-状态统计-认证

状态统计

在nginx.conf的server中加入:

location /info {
stub_status; #返回nginx的状态统计信息
access_log off;
}

访问info会得到:

Active connections: 1
server accepts handled requests
10 10 26
Reading: 0 Writing: 1 Waiting: 0

具体内容解释可以看:stub_status模块官方文档

Active connections
The current number of active client connections including Waiting connections.
当前活动客户端连接数,包括 Waiting 连接。
accepts
The total number of accepted client connections.
接受的客户端连接总数。
handled
The total number of handled connections. Generally, the parameter value is the same as accepts unless some resource limits have been reached (for example, the worker_connections limit).
已处理连接的总数。通常,参数值与 accepts 相同,除非已达到某些资源限制(例如,worker_connections限制)。
requests
The total number of client requests.
客户端请求的总数。
Reading
The current number of connections where nginx is reading the request header.
nginx正在阅读请求头的当前连接数。
Writing
The current number of connections where nginx is writing the response back to the client.
nginx将响应写回客户端的当前连接数。
Waiting
The current number of idle client connections waiting for a request.
当前等待请求的空闲客户端连接数。

认证功能auth_basic-module

location /info {
                stub_status;    #返回nginx的状态统计信息
                access_log off;
                auth_basic "north website";
                auth_basic_user_file htpasswd;
        }

1、先安装htpasswd

yum install httpd-tools -y

2、用htpasswd命令在nginx的安装路径下的conf中创建一个文件并建立一个用户保存到到htpasswd中

[root@localhost conf]# htpasswd -c /usr/local/nginx_1/conf/htpasswd north
New password:
Re-type new password:
Adding password for user north

3、现在去访问状态统计页面就会需要输入用户名和密码

提供下载功能

location / {
            root   html;
            autoindex on; #将目录里的内容显示出
            index  north/north.html index.html index.htm;
        }

nginx修改进程打开文件数量限制

永久修改进程打开文件数量限制:

vim /etc/security/limits.conf
临时修改:
ulimit -n 数量

#<domain>      <type>  <item>         <value>
#
*               soft    1000000
*               hard    1000000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值