nginx配置防止ddos攻击和cc攻击
时间:2015-06-28 18:45 来源:linux.it.net.cn 作者:IT
经常会有一些无聊的人,对网站发起ddos攻击或者cc攻击。
可以在nginx上做一下限制来防止类似攻击。如下配置nginx.conf文件内容:
##
# Basic Settings
##
keepalive_timeout 30;
types_hash_max_size 2048;
##
# Performance Settings
##
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 Protection Settings
##
client_body_buffer_size 128k;
large_client_header_buffers 4 256k;
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;
配置之后需要重启nignx , 重启命令service nignx restart
配置的详细说明请参考:http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html
(责任编辑:IT)
经常会有一些无聊的人,对网站发起ddos攻击或者cc攻击。 可以在nginx上做一下限制来防止类似攻击。如下配置nginx.conf文件内容: ## # Basic Settings ## keepalive_timeout 30; types_hash_max_size 2048; ## # Performance Settings ## 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 Protection Settings ## client_body_buffer_size 128k; large_client_header_buffers 4 256k; 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; 配置之后需要重启nignx , 重启命令service nignx restart 配置的详细说明请参考:http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html (责任编辑:IT) |