Saltstack Official Apache Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
3.4KB

  1. {%- set apache = pillar.get('apache', {}) %}
  2. {%- set modsec = apache.get('mod_security', {}) %}
  3. {%- set sec_rule_engine = modsec.get('sec_rule_engine', 'DetectionOnly' ) -%}
  4. {%- set sec_request_body_access = modsec.get('sec_request_body_access', 'On' ) -%}
  5. {%- set sec_request_body_limit = modsec.get('sec_request_body_limit', 13107200 ) -%}
  6. {%- set sec_request_body_no_files_limit = modsec.get('sec_request_body_no_files_limit', 131072 ) -%}
  7. {%- set sec_request_body_in_memory_limit = modsec.get('sec_request_body_in_memory_limit', 131072 ) -%}
  8. {%- set sec_request_body_limit_action = modsec.get('sec_request_body_limit_action', 'Reject' ) -%}
  9. {%- set sec_pcre_match_limit = modsec.get('sec_pcre_match_limit', 1000 ) -%}
  10. {%- set sec_pcre_match_limit_recursion = modsec.get('sec_pcre_match_limit_recursion', 1000 ) -%}
  11. {%- set sec_debug_log_level = modsec.get('sec_debug_log_level', 0 ) -%}
  12. #
  13. # This file is managed by Salt! Do not edit by hand!
  14. # Modify the salt pillar that generates this file instead
  15. #
  16. LoadModule security2_module modules/mod_security2.so
  17. <IfModule mod_security2.c>
  18. # ModSecurity Core Rules Set configuration
  19. IncludeOptional modsecurity.d/*.conf
  20. IncludeOptional modsecurity.d/activated_rules/*.conf
  21. # Default recommended configuration
  22. SecRuleEngine {{ sec_rule_engine }}
  23. SecRequestBodyAccess {{ sec_request_body_access }}
  24. SecRule REQUEST_HEADERS:Content-Type "text/xml" \
  25. "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
  26. SecRequestBodyLimit {{ sec_request_body_limit }}
  27. SecRequestBodyNoFilesLimit {{ sec_request_body_no_files_limit }}
  28. SecRequestBodyInMemoryLimit {{ sec_request_body_in_memory_limit }}
  29. SecRequestBodyLimitAction {{ sec_request_body_limit_action }}
  30. SecRule REQBODY_ERROR "!@eq 0" \
  31. "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
  32. SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
  33. "id:'200002',phase:2,t:none,log,deny,status:44,msg:'Multipart request body \
  34. failed strict validation: \
  35. PE %{REQBODY_PROCESSOR_ERROR}, \
  36. BQ %{MULTIPART_BOUNDARY_QUOTED}, \
  37. BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
  38. DB %{MULTIPART_DATA_BEFORE}, \
  39. DA %{MULTIPART_DATA_AFTER}, \
  40. HF %{MULTIPART_HEADER_FOLDING}, \
  41. LF %{MULTIPART_LF_LINE}, \
  42. SM %{MULTIPART_MISSING_SEMICOLON}, \
  43. IQ %{MULTIPART_INVALID_QUOTING}, \
  44. IP %{MULTIPART_INVALID_PART}, \
  45. IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
  46. FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
  47. SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
  48. "id:'200003',phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"
  49. SecPcreMatchLimit {{ sec_pcre_match_limit }}
  50. SecPcreMatchLimitRecursion {{ sec_pcre_match_limit_recursion }}
  51. SecRule TX:/^MSC_/ "!@streq 0" \
  52. "id:'200004',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
  53. SecResponseBodyAccess Off
  54. SecDebugLog /var/log/apache2/modsec_debug.log
  55. SecDebugLogLevel {{ sec_debug_log_level }}
  56. SecAuditEngine RelevantOnly
  57. SecAuditLogRelevantStatus "^(?:5|4(?!04))"
  58. SecAuditLogParts ABIJDEFHZ
  59. SecAuditLogType Serial
  60. SecAuditLog /var/log/apache2/modsec_audit.log
  61. SecArgumentSeparator &
  62. SecCookieFormat 0
  63. SecTmpDir /var/lib/mod_security
  64. SecDataDir /var/lib/mod_security
  65. </IfModule>