nginx防hashdos模块释出
hashdos这个事,严格意义上不是各种语言的错了(不过perl的确处理得很好)。
借鉴tomcat的作法,实现了下面这个nginx-http-hashdos-module,通过设置hashdos(默认on)的开关和body_max_count(默认值1000),对nginx后面的服务进行安全防护,相比对php或者java进行patch,这或许是最好的办法了。
nginx-http-hashdos-module项目地址
https://github.com/54chen/nginx-http-hashdos-module
如何使用
1.下载zip后保存到一个目录,如~/nginx-http-hashdos-module。
2.cd nginx-1.0.9/
3.重新编译和安装nginx
./configure --prefix=/opt/soft/nginx --with-pcre --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-debug --add-module=/path_to/nginx-http-hashdos-module/ && make && make install
4.配置打开:
hashdos on;
body_max_count 1000;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /opt/soft/nginx/conf/fastcgi_params;
client_body_buffer_size 2m;
client_max_body_size 2m;
}
注意事项
因为计算参数都在内存中进行,所以client_body_buffer_size 与 client_max_body_size 的值一定要相等。推荐2m。
TODO
改进in-file时的post分析。
https://github.com/54chen/nginx-http-hashdos-module
建议继续学习:
扫一扫订阅我的微信号:IT技术博客大学习
- 作者:54chen 来源: 五四陈科学院-坚信科学,分享技术
- 标签: hashdos
- 发布时间:2012-01-08 22:07:56
-
[927] WordPress插件开发 -- 在插件使用 -
[126] 解决 nginx 反向代理网页首尾出现神秘字 -
[51] 如何保证一个程序在单台服务器上只有唯一实例( -
[50] 整理了一份招PHP高级工程师的面试题 -
[48] CloudSMS:免费匿名的云短信 -
[48] Innodb分表太多或者表分区太多,会导致内 -
[48] 用 Jquery 模拟 select -
[48] 全站换域名时利用nginx和javascri -
[48] 海量小文件存储 -
[46] ps 命令常见用法
