Apache header directives for security
This is a list of header directives for to increment security site.
You have two ways for set this security header, from .htacess or from your web server.
Example using ".htaccess"
<IfModule mod_headers.c>
Header set X-Frame-Options "DENY"
</IfModule>
You can set using "Header set" followed by header policy.
This is a list from more commons.
Content-Security-Policy
Examples 1
<IfModule mod_headers.c>
Header set Content-Security-Policy "default-src 'self' style-src 'self' 'unsafe-inline' fonts.googleapis.com script-src 'self' font-src 'self' fonts.gstatic.com "
</IfModule>
You can find a complete documentation on this link:
Directives for bootstrap
https://content-security-policy.com/examples/google-fonts/
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
Strict Transport Security
Examples 1
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000"
</IfModule>
X Frame Options
Examples 1
<IfModule mod_headers.c>
Header set X-Frame-Options "SAMEORIGIN"
</IfModule>
X Content Type Options
Examples 1
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
</IfModule>
X XSS Protection
Examples 1
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
</IfModule>
Cache Control
Examples 1
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
</IfModule>
References:
https://csplite.com/csp31/
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
https://crashtest-security.com/enable-security-headers/#webserverconfiguration
Comments
Post a Comment