added denial of TRACE and CONNECT methods
This commit is contained in:
		
							parent
							
								
									48117e4d3f
								
							
						
					
					
						commit
						ff4f498d2b
					
				|  | @ -91,5 +91,6 @@ defaults_apache: | ||||||
| 
 | 
 | ||||||
|   security: |   security: | ||||||
|     restricted_methods: ['GET', 'POST', 'HEAD'] |     restricted_methods: ['GET', 'POST', 'HEAD'] | ||||||
|  |     dangerous_methods: ['TRACE', 'CONNECT'] | ||||||
| 
 | 
 | ||||||
| debug: false | debug: false | ||||||
|  |  | ||||||
|  | @ -26,7 +26,8 @@ defaults_site: | ||||||
|   security:  # https://www.nixpal.com/apache-httpd-hardening/ |   security:  # https://www.nixpal.com/apache-httpd-hardening/ | ||||||
|     disable_root_index: true |     disable_root_index: true | ||||||
|     disable_ssi_cgi: true |     disable_ssi_cgi: true | ||||||
|     restrict_methods: true |     restrict_methods: true  # disable anything but GET/POST/HEAD methods; if you're running a web-application you might need to disable this filter | ||||||
|  |     deny_dangerous_methods: true  # if 'restrict_methods' is disabled - this will still deny 'TRACE' & 'CONNECT' as they might open your server/services up to attacks | ||||||
| 
 | 
 | ||||||
|   redirect: |   redirect: | ||||||
|     target: 'https://github.com/ansibleguy' |     target: 'https://github.com/ansibleguy' | ||||||
|  |  | ||||||
|  | @ -18,15 +18,26 @@ | ||||||
| {% endif %} | {% endif %} | ||||||
| 
 | 
 | ||||||
|   # security config |   # security config | ||||||
| {% if site.security.restrict_methods %} | {% if site.security.restrict_methods | bool %} | ||||||
|   <IfModule mod_rewrite.c> |   <IfModule mod_rewrite.c> | ||||||
|     RewriteEngine On |     RewriteEngine On | ||||||
|     RewriteCond %{REQUEST_METHOD} ^(?!{% for method in APACHE_CONFIG.security.restricted_methods %}{{ method }}{% if not loop.last %}|{% endif %}{% endfor %}) |     RewriteCond %{REQUEST_METHOD} ^(?!{{ for method in APACHE_CONFIG.security.restricted_methods | join('|') }}) | ||||||
|     RewriteRule .* - [F] |     RewriteRule .* - [L,R=405] | ||||||
|   </IfModule> |   </IfModule> | ||||||
|   <Directory /> |   <Directory /> | ||||||
|     <LimitExcept {% for method in APACHE_CONFIG.security.restricted_methods %}{{ method }} {% endfor %}> |     <LimitExcept {% for method in APACHE_CONFIG.security.restricted_methods %}{{ method }} {% endfor %}> | ||||||
|       Require all denied |       Require all denied | ||||||
|     </LimitExcept> |     </LimitExcept> | ||||||
|   </Directory> |   </Directory> | ||||||
|  | {% elif site.security.deny_dangerous_methods | bool %} | ||||||
|  |   <IfModule mod_rewrite.c> | ||||||
|  |     RewriteEngine On | ||||||
|  |     RewriteCond %{REQUEST_METHOD} ^({{ for method in APACHE_CONFIG.security.dangerous_methods | join('|') }}) | ||||||
|  |     RewriteRule .* - [L,R=405] | ||||||
|  |   </IfModule> | ||||||
|  |   <Directory /> | ||||||
|  |     <Limit {% for method in APACHE_CONFIG.security.dangerous_methods %}{{ method }} {% endfor %}> | ||||||
|  |       Require all denied | ||||||
|  |     </Limit> | ||||||
|  |   </Directory> | ||||||
| {% endif %} | {% endif %} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue