当前位置: 首页 > news >正文

广州网站设计公司济南兴田德润o简介图片查网站域名

广州网站设计公司济南兴田德润o简介图片,查网站域名,网站备案需要审核多久,个体制作网站设计文章目录 前言一、ngx_http_limit_conn_module二、指令介绍1. limit_conn_zone2.limit_conn3. limit_conn_log_level4. limit_conn_status 案例未限制限制 总结 前言 瞬时大量用户访问服务器,导致服务器超载而宕机。 恶意请求攻击服务器,导致服务器超载…

文章目录

  • 前言
  • 一、ngx_http_limit_conn_module
  • 二、指令介绍
    • 1. limit_conn_zone
    • 2.limit_conn
    • 3. limit_conn_log_level
    • 4. limit_conn_status
  • 案例
    • 未限制
    • 限制
  • 总结


前言

瞬时大量用户访问服务器,导致服务器超载而宕机。
恶意请求攻击服务器,导致服务器超载而宕机。
nginx如何限制每个客户端的并发连接数?


一、ngx_http_limit_conn_module

生效阶段: NGX_HTTP_PREACCESS_PHASE
模块默认编译进nginx,通过–without-http_limit_conn_module禁用。
生效范围:

  • 全部worker进程(基于共享内存)
  • 进入preaccess阶段前不生效
  • 限制的有效性取决于key的设计:依赖postread阶段的realip模块取到真实的IP。
    ngx_http_limit_conn_module官方传送门

二、指令介绍

1. limit_conn_zone

定义共享内存(包含大小),以及key关键字
代码如下(示例):

Syntax:	limit_conn_zone key zone=name:size;
Default:	—
Context:	http

2.limit_conn

限制并发连接数
代码如下(示例):

Syntax:	limit_conn zone number;
Default:	—
Context:	http, server, location

3. limit_conn_log_level

限制发生时的日志级别

Syntax:	limit_conn_log_level info | notice | warn | error;
Default:	
limit_conn_log_level error;
Context:	http, server, location
This directive appeared in version 0.8.18.

4. limit_conn_status

限制发生时向客户端返回的错误码

Syntax:	limit_conn_status code;
Default:	
limit_conn_status 503;
Context:	http, server, location
This directive appeared in version 1.3.15.

案例

未限制

现在limit_conn是注释状态

[root@test20 nginx]# cat conf.d/limit_conn.conf 
limit_conn_zone $binary_remote_addr zone=addr:10m;server {server_name limit_conn.test.io;root html/;error_log  /var/log/nginx/myerror.log info;        location / {#limit_conn_status 500;#limit_conn_log_level warn;#limit_conn addr 1;}
}
# 如上,定义了一个addr的共享区域,用$binary_remote_addr作为key。# 用ab 压测
ab -c 1000 -n 100000 http://limit_conn.test.io/limit.html# 查看access.log的内容,分析返回状态码,全部返回200
[root@test20 nginx]# cat /var/log/nginx/access.log | awk -F' ' '{print $9}' | sort | uniq -c1 100000 200

限制

[root@test20 nginx]# cat conf.d/limit_conn.conf 
limit_conn_zone $binary_remote_addr zone=addr:10m;server {server_name limit_conn.test.io;root html/;error_log  /var/log/nginx/myerror.log info;        location / {limit_conn_status 500;limit_conn_log_level warn;limit_conn addr 1;}
}
# 如上,定义了一个addr的共享区域,用$binary_remote_addr作为key。# 用ab 压测
ab -c 1000 -n 100000 http://limit_conn.test.io/limit.html# 查看access.log的内容,分析返回状态码,有部分返回了500
[root@test20 nginx]# cat /var/log/nginx/access.log | awk -F' ' '{print $9}' | sort | uniq -c1 170998 2002676 500

总结

下一节,介绍nginx限流

http://www.hkea.cn/news/528101/

相关文章:

  • 怎么做app网站seo学习网站
  • 广西建设职业技术学院官网免费的seo优化
  • 凡科网电脑版怎么做网站百度知道官网手机版
  • 贵卅省住房和城乡建设厅网站周口seo推广
  • 搭建flv视频网站seo工具查询
  • 企业展示网站 数据库设计模板自助建站
  • 房地产设计师上海seo网络优化
  • wordpress迁移打不开百度seo泛解析代发排名
  • 网站兼容性测试怎么做微信营销软件群发
  • wordpress如何设置内容页seo营销优化
  • 高端大气的网站制作南宁百度seo软件
  • 沙井营销型网站建设成人培训机构
  • 网站没有被百度收录搜索引擎排名优化公司
  • 手机网站转换小程序晋江怎么交换友情链接
  • 专业做网站的公司疫情放开最新消息今天
  • 不用写代码做网站软件长沙优化网站
  • o2o商城网站建设方案广告策划案优秀案例
  • 日照做网站的那家做的好百度网页链接
  • 建设云个人证件查询系统上海seo培训
  • 网站流量提供商杭州seo排名
  • 做装饰工程的在什么网站投标自建站
  • 地球人--一家只做信誉的网站帮忙推广的平台
  • 网站建设外包协议天津网站排名提升
  • 邯郸教育行业网站建设百度推广代理商查询
  • 政府网站有哪些网站seo最新优化方法
  • 做广告牌子seo外链工具
  • 微信页面设计网站兰州网络推广技术
  • 上门做网站搜狗站长工具
  • wordpress用户邮箱验证码百度seo搜索引擎优化培训
  • 360极速怎么屏蔽网站新闻热点大事件