security.j2 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {% if ansible_prolog -%}
  2. {% from 'templates/ansible/prolog.j2' import prolog with context %}
  3. {{ prolog() }}
  4. {% endif -%}
  5. #
  6. # Disable access to the entire file system except for the directories that
  7. # are explicitly allowed later.
  8. #
  9. # This currently breaks the configurations that come with some web application
  10. # Debian packages.
  11. #
  12. #<Directory />
  13. # AllowOverride None
  14. # Order Deny,Allow
  15. # Deny from all
  16. #</Directory>
  17. # Changing the following options will not really affect the security of the
  18. # server, but might make attacks slightly more difficult in some cases.
  19. #
  20. # ServerTokens
  21. # This directive configures what you return as the Server HTTP response
  22. # Header. The default is 'Full' which sends information about the OS-Type
  23. # and compiled in modules.
  24. # Set to one of: Full | OS | Minimal | Minor | Major | Prod
  25. # where Full conveys the most information, and Prod the least.
  26. #
  27. #ServerTokens Minimal
  28. ServerTokens Prod
  29. #ServerTokens Full
  30. #
  31. # Optionally add a line containing the server version and virtual host
  32. # name to server-generated pages (internal error documents, FTP directory
  33. # listings, mod_status and mod_info output etc., but not CGI generated
  34. # documents or custom error documents).
  35. # Set to "EMail" to also include a mailto: link to the ServerAdmin.
  36. # Set to one of: On | Off | EMail
  37. #
  38. #ServerSignature Off
  39. ServerSignature Off
  40. #
  41. # Allow TRACE method
  42. #
  43. # Set to "extended" to also reflect the request body (only for testing and
  44. # diagnostic purposes).
  45. #
  46. # Set to one of: On | Off | extended
  47. #
  48. TraceEnable Off
  49. #TraceEnable On
  50. #
  51. # SSL enforcement
  52. #
  53. <IfModule mod_ssl.c>
  54. SSLProtocol all -SSLv3 -SSLv2 -TLSv1
  55. {% if apache2_ssl_strengthened %}
  56. SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
  57. {% else %}
  58. SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
  59. {% endif %}
  60. SSLHonorCipherOrder on
  61. <IfVersion >= 2.4>
  62. SSLCompression off
  63. SSLUseStapling on
  64. SSLStaplingResponderTimeout 5
  65. SSLStaplingReturnResponderErrors off
  66. SSLStaplingCache shmcb:/var/run/ocsp(128000)
  67. </IfVersion>
  68. </IfModule>
  69. #
  70. # Forbid access to version control directories
  71. #
  72. # If you use version control systems in your document root, you should
  73. # probably deny access to their directories. For example, for subversion:
  74. #
  75. <DirectoryMatch "/\.(svn|git)">
  76. Deny from all
  77. Satisfy all
  78. </DirectoryMatch>
  79. #
  80. # Setting this header will prevent MSIE from interpreting files as something
  81. # else than declared by the content type in the HTTP headers.
  82. # Requires mod_headers to be enabled.
  83. #
  84. <IfModule mod_headers.c>
  85. Header set X-Content-Type-Options: "nosniff"
  86. </IfModule>
  87. #
  88. # Some browsers have a built-in XSS filter that will detect some cross site
  89. # scripting attacks. By default, these browsers modify the suspicious part of
  90. # the page and display the result. This behavior can create various problems
  91. # including new security issues. This header will tell the XSS filter to
  92. # completely block access to the page instead.
  93. # Requires mod_headers to be enabled.
  94. #
  95. <IfModule mod_headers.c>
  96. Header set X-XSS-Protection: "1; mode=block"
  97. </IfModule>
  98. #
  99. # Setting this header will prevent other sites from embedding pages from this
  100. # site as frames. This defends against clickjacking attacks.
  101. # Requires mod_headers to be enabled.
  102. #
  103. <IfModule mod_headers.c>
  104. Header set X-Frame-Options: "sameorigin"
  105. </IfModule>
  106. #
  107. # Various protections
  108. # - stuff that should not be accessible publicly
  109. # - PHP files that should be invoked
  110. #
  111. <DirectoryMatch "/atos/param/">
  112. Deny from all
  113. Satisfy all
  114. </DirectoryMatch>
  115. <LocationMatch "/wp-content/uploads/.*\.php.*">
  116. Deny from all
  117. Satisfy all
  118. </LocationMatch>
  119. <Location "/xmlrpc.php">
  120. Deny from all
  121. Satisfy all
  122. </Location>