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

nginx 另一WAF方式

 
 
  1. nginx 另一WAF方式 
  2. 2013-03-01 10:57 116人阅读 评论(0) 收藏 举报 
  3. 使用方法: 
  4. vi /usr/local/nginx/conf/drop_sql.conf 
  5. 添加以下内容 
  6. 代码: 
  7. ## Block SQL injections 
  8. set $block_sql_injections 0; 
  9. if ($query_string ~ "union.*select.*\(") { 
  10. set $block_sql_injections 1; 
  11. if ($query_string ~ "union.*all.*select.*") { 
  12. set $block_sql_injections 1; 
  13. if ($query_string ~ "concat.*\(") { 
  14. set $block_sql_injections 1; 
  15. if ($block_sql_injections = 1) { 
  16. return 403; 
  17.  
  18. ## Block file injections 
  19. set $block_file_injections 0; 
  20. if ($query_string ~ "[a-zA-Z0-9_]=http://") { 
  21. set $block_file_injections 1; 
  22. if ($query_string ~ "[a-zA-Z0-9_]=(\.\.//?)+") { 
  23. set $block_file_injections 1; 
  24. if ($query_string ~ "[a-zA-Z0-9_]=/([a-z0-9_.]//?)+") { 
  25. set $block_file_injections 1; 
  26. if ($block_file_injections = 1) { 
  27. return 403; 
  28.  
  29. ## Block common exploits 
  30. set $block_common_exploits 0; 
  31. if ($query_string ~ "(<|%3C).*script.*(>|%3E)") { 
  32. set $block_common_exploits 1; 
  33. if ($query_string ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})") { 
  34. set $block_common_exploits 1; 
  35. if ($query_string ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})") { 
  36. set $block_common_exploits 1; 
  37. if ($query_string ~ "proc/self/environ") { 
  38. set $block_common_exploits 1; 
  39. if ($query_string ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3D)") { 
  40. set $block_common_exploits 1; 
  41. if ($query_string ~ "base64_(en|de)code\(.*\)") { 
  42. set $block_common_exploits 1; 
  43. if ($block_common_exploits = 1) { 
  44. return 403; 
  45.  
  46. ## Block spam 
  47. set $block_spam 0; 
  48. if ($query_string ~ "\b(ultram|unicauca|valium|viagra|vicodin|xanax|ypxaieo)\b") { 
  49. set $block_spam 1; 
  50. if ($query_string ~ "\b(erections|hoodia|huronriveracres|impotence|levitra|libido)\b") { 
  51. set $block_spam 1; 
  52. if ($query_string ~ "\b(ambien|blue\spill|cialis|cocaine|ejaculation|erectile)\b") { 
  53. set $block_spam 1; 
  54. if ($query_string ~ "\b(lipitor|phentermin|pro[sz]ac|sandyauer|tramadol|troyhamby)\b") { 
  55. set $block_spam 1; 
  56. if ($block_spam = 1) { 
  57. return 403; 
  58.  
  59. ## Block user agents 
  60. set $block_user_agents 0; 
  61.  
  62. # Don't disable wget if you need it to run cron jobs! 
  63. #if ($http_user_agent ~ "Wget") { 
  64. # set $block_user_agents 1; 
  65. #} 
  66.  
  67. # Disable Akeeba Remote Control 2.5 and earlier 
  68. if ($http_user_agent ~ "Indy Library") { 
  69. set $block_user_agents 1; 
  70.  
  71. # Common bandwidth hoggers and hacking tools. 
  72. if ($http_user_agent ~ "libwww-perl") { 
  73. set $block_user_agents 1; 
  74. if ($http_user_agent ~ "GetRight") { 
  75. set $block_user_agents 1; 
  76. if ($http_user_agent ~ "GetWeb!") { 
  77. set $block_user_agents 1; 
  78. if ($http_user_agent ~ "Go!Zilla") { 
  79. set $block_user_agents 1; 
  80. if ($http_user_agent ~ "Download Demon") { 
  81. set $block_user_agents 1; 
  82. if ($http_user_agent ~ "Go-Ahead-Got-It") { 
  83. set $block_user_agents 1; 
  84. if ($http_user_agent ~ "TurnitinBot") { 
  85. set $block_user_agents 1; 
  86. if ($http_user_agent ~ "GrabNet") { 
  87. set $block_user_agents 1; 
  88.  
  89. if ($block_user_agents = 1) { 
  90. return 403; 
  91.  
  92. 在nginx.conf配置文件中的server段中加入 
  93. include drop_sql.conf; 
  94.  
  95. 重新加载nginx配置文件即可生效 
  96. /usr/local/nginx/sbin/nginx -s reload 

 本文转自it你好 51CTO博客,原文链接:http://blog.51cto.com/itnihao/745950,如需转载请自行联系原作者

相关文章:

  • 修改Linux的22端口几种方法
  • 再谈谈火车票系统
  • 模式--创建型
  • Just for fun——迅速写完快速排序
  • 十六进制之间的转换(二进制、八进制、十六进制、十进制)
  • php7.1.1一键安装/配置文件简单优化
  • Office 365中管理员角色介绍-进阶篇
  • SQL Server-表表达式基础
  • Oracle 11g RAC 故障之--Instance 启动失败
  • Nginx基于用户名和密码的访问控制
  • VS2005和ASP.NET2.0中使用强类型数据
  • HTML 简介
  • 开机取消按Ctrl+Alt+Del键
  • Android录制视频报错setVideoSize called in a invalid state 1
  • android自动化测试中hierarchyviewer和uiautomatorviewer获取控件信息的方式比对(1)
  • 【许晓笛】 EOS 智能合约案例解析(3)
  • Druid 在有赞的实践
  • HTTP中GET与POST的区别 99%的错误认识
  • leetcode378. Kth Smallest Element in a Sorted Matrix
  • Odoo domain写法及运用
  • pdf文件如何在线转换为jpg图片
  • Python_网络编程
  • Vue实战(四)登录/注册页的实现
  • 纯 javascript 半自动式下滑一定高度,导航栏固定
  • 给初学者:JavaScript 中数组操作注意点
  • 官方解决所有 npm 全局安装权限问题
  • 面试总结JavaScript篇
  • 世界上最简单的无等待算法(getAndIncrement)
  • 无服务器化是企业 IT 架构的未来吗?
  • 一个JAVA程序员成长之路分享
  • 白色的风信子
  • puppet连载22:define用法
  • ​MySQL主从复制一致性检测
  • # 达梦数据库知识点
  • #AngularJS#$sce.trustAsResourceUrl
  • #宝哥教你#查看jquery绑定的事件函数
  • (4)logging(日志模块)
  • (C语言)共用体union的用法举例
  • (vue)页面文件上传获取:action地址
  • (附源码)springboot家庭财务分析系统 毕业设计641323
  • (附源码)springboot家庭装修管理系统 毕业设计 613205
  • (已解决)报错:Could not load the Qt platform plugin “xcb“
  • (转)【Hibernate总结系列】使用举例
  • (转)MVC3 类型“System.Web.Mvc.ModelClientValidationRule”同时存在
  • (转)shell中括号的特殊用法 linux if多条件判断
  • .NET 使用 JustAssembly 比较两个不同版本程序集的 API 变化
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .NET/C# 中你可以在代码中写多个 Main 函数,然后按需要随时切换
  • .NET简谈互操作(五:基础知识之Dynamic平台调用)
  • .net专家(张羿专栏)
  • ;号自动换行
  • ??在JSP中,java和JavaScript如何交互?
  • [51nod1610]路径计数
  • [Angular] 笔记 9:list/detail 页面以及@Output
  • [BZOJ] 3262: 陌上花开