#优化:Nginx防御DDOS和CC攻击
加载HTTP段 ##
# 基础配置
##
keepalive_timeout 10;
server_tokens off;
types_hash_max_size 2048;
##
# 主要配置
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
open_file_cache max=50000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
##
# DDoS 和 CC 防御配置,主要是限制链接数,详细:http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html
##
client_body_buffer_size 128k;
large_client_header_buffers 4 32k;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
client_max_body_size 50m; limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=50r/s;
limit_conn conn_limit_per_ip 20;
limit_req zone=req_limit_per_ip burst=20; 完整的nginx配置文件
[root@panni ~]# cat /etc/nginx/nginx.conf
user nobody;
worker_processes auto; error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 1024; events {
use epoll;
worker_connections 1024;
multi_accept on; } http {
include /etc/nginx/mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; ##
# 基础配置
##
keepalive_timeout 10;
server_tokens off;
types_hash_max_size 2048;
##
# 主要配置
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
open_file_cache max=50000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
##
# DDoS 和 CC 防御配置,主要是限制链接数,详细:http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html
##
client_body_buffer_size 128k;
large_client_header_buffers 4 32k;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
client_max_body_size 50m; limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=50r/s;
limit_conn conn_limit_per_ip 20;
limit_req zone=req_limit_per_ip burst=20; fastcgi_connect_timeout 300; #如果你不使用FastCGI,请用井号注释该段每一行
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k; gzip on; #如果你不使用GZip,请用井号注释该段每一行
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\."; include /etc/nginx/conf.d/*.conf;
}
#优化:Nginx防御DDOS和CC攻击的更多相关文章
- 使用Nginx的配置对cc攻击进行简单防御
ddos攻击:分布式拒绝服务攻击,就是利用大量肉鸡或伪造IP,发起大量的服务器请求,最后导致服务器瘫痪的攻击. cc攻击:类似于ddos攻击,不过它的特点是主要是发起大量页面请求,所以流量不大,但是却 ...
- DDOS和cc攻击的防御
DDOS和cc攻击的防御 author:headsen chen 2017-10-21 10:47:39 个人原创,转载请注明作者,否则依法追究法律责任: DDOS攻击形式:黑客挟持多个电脑( ...
- nginx防DDOS、cc、爬虫攻击
一.防止DDOS.CC攻击 http { limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_nam ...
- OpenResty(nginx扩展)实现防cc攻击
OpenResty(nginx扩展)实现防cc攻击 导读 OpenResty 通过汇聚各种设计精良的 Nginx 模块(主要由 OpenResty 团队自主开发),从而将 Nginx 有效地变成一个强 ...
- 使用iptables缓解DDOS及CC攻击
使用iptables缓解DDOS及CC攻击 LINUX 追马 7个月前 (02-09) 465浏览 0评论 缓解DDOS攻击 防止SYN攻击,轻量级预防 iptables -N syn-flo ...
- Nginx配置抵御DDOS或CC攻击
防攻击的思路我们都明白,比如限制IP啊,过滤攻击字符串啊,识别攻击指纹啦.可是要如何去实现它呢?用守护脚本吗?用PHP在外面包一层过滤?还是直接加防火墙吗?这些都是防御手段.不过本文将要介绍的是直接通 ...
- DDos、CC攻击与防御
DDoS介绍 DDoS是英文Distributed Denial of Service的缩写,意即"分布式拒绝服务",那么什么又是拒绝服务(Denial of Service)呢? ...
- cc攻击怎么防御,如何防止cc攻击?
当我们访问一个网站时,如果网站页面越简单,访问速度越快,页面越漂亮,加载速度就越慢,因为要加载更多东西,服务器压力也会比较大.cc攻击就是利用这种弱点,使用大量代理服务器,对网站进行攻击,消耗网站服务 ...
- DDos与CC攻击的简单个人理解
DDos简单来说就是向指定IP发送大量无用的数据包,造成网卡堵塞. CC理解成模拟表单提交,真实模拟业务,但量大之后也会造成网络堵塞. 参考: http://www.enkj.com/idcnews/ ...
随机推荐
- win7下安装matlab后打开出错“error starting desktop”的解决办法
在matlab快捷图标上右键,选择"还原以前的版本"--"兼容性"选项卡,在"以兼容模式运行这个程序"前面打勾,并选择"windo ...
- linux cp 命令详解
/home/lee#cp --help 用法:cp [选项]... 来源 目的地 或:cp [选项]... 来源... 目录 或:cp [选项]... --target-directory=目录 来源 ...
- Hadoop: Add third-party libraries to MapReduce job
来自:http://hadoopi.wordpress.com/2014/06/05/hadoop-add-third-party-libraries-to-mapreduce-job/ Anybod ...
- Flex报错Error #2048: 安全沙箱冲突
Flex+JPA架构,JPA程序迁移,从Aserver到B. 其它一切没变.唯一变的就是IP. 前端Flex也就是swf报错Error #2048: 安全沙箱冲突:http://xxx.swf 不能从 ...
- unity的 Social API
孙广东 2015.12.23 Social API Social API 是訪问的Unity 的point 社会功能.如:• 用户配置文件• 好友列表• 成就• 统计 / 排行榜 它提供了 ...
- unique-paths I &II 路径数,动态规划
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...
- 【DB2】监控临时表空间使用
在我们使用数据库的时候,我们都知道应用程序在DB2上运行时,会产生临时表空间,我们想要监测这些临时表空间的使用情况,可以使用以下步骤: (1)打开monitor switches 中的table监视器 ...
- Ubuntu中的Gif动画录制工具
为了在随笔中插入gif动态图Windows系统上可以使用ScreenToGif这个非常好用的小软件,在Ubuntu系统中选择也很多(可以参考最下面的链接),下面介绍两款ubuntu系统中的录屏软件: ...
- 8、redis之事务1-redis命令
一.概述: 和众多其它数据库一样,Redis作为NoSQL数据库也同样提供了事务机制.在Redis中,MULTI/EXEC/DISCARD/WATCH这四个命令是我们实现事务的基石.相信对有 ...
- 转 php简单伪静态实例
mod_rewrite是Apache的一个非常强大的功能,它可以实现伪静态页面.下面我详细说说它的使用方法!对初学者很有用的哦! 1.检测Apache是否支持mod_rewrite 通过php提供的p ...