Skip to content

Commit 4644fbb

Browse files
committed
Update .htaccess
1 parent c280b8f commit 4644fbb

File tree

1 file changed

+57
-8
lines changed

1 file changed

+57
-8
lines changed

dist/.htaccess

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,68 @@ AddDefaultCharset utf-8
464464
# This can be done by setting a `Content Security Policy` which
465465
# whitelists trusted sources of content for your website.
466466
#
467-
# The example header below allows ONLY scripts that are loaded from
468-
# the current website's origin (no inline scripts, no CDN, etc).
469-
# That almost certainly won't work as-is for your website!
467+
# There is no policy that fits all websites, you will have to modify
468+
# the `Content-Security-Policy` directives in the example below depending
469+
# on your needs.
470470
#
471-
# To make things easier, you can use an online CSP header generator
472-
# such as: https://www.cspisawesome.com/.
471+
# The example policy below aims to:
473472
#
473+
# (1) Restrict all fetches by default to the origin of the current website
474+
# by setting the `default-src` directive to `'self'` - which acts as a
475+
# fallback to all "Fetch directives" (https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive).
476+
#
477+
# This is convenient as you do not have to specify all Fetch directives
478+
# that apply to your site, for example:
479+
# `connect-src 'self'; font-src 'self'; script-src 'self'; style-src 'self'`, etc.
480+
#
481+
# This restriction also means that you must explicitly define from
482+
# which site(s) your website is allowed to load resources from.
483+
#
484+
# (2) The `<base>` element is not allowed on the website. This is to
485+
# prevent attackers from changing the locations of resources loaded
486+
# from relative URLs.
487+
#
488+
# If you want to use the `<base>` element, then `base-uri 'self'`
489+
# can be used instead.
490+
#
491+
# (3) Form submissions are only allowed from the current website by
492+
# setting: `form-action 'self'`.
493+
#
494+
# (4) Prevents all websites (including your own) from embedding your
495+
# webpages within e.g. the `<iframe>` or `<object>` element by
496+
# setting `frame-ancestors 'none'`.
497+
#
498+
# The `frame-ancestors` directive helps avoid "Clickjacking" attacks
499+
# and is similar to the `X-Frame-Options` header.
500+
#
501+
# Browsers that support the CSP header will ignore `X-Frame-Options`
502+
# if `frame-ancestors` is also specified.
503+
#
504+
# (5) Forces the browser to treat all the resources that are served over
505+
# HTTP as if they were loaded securely over HTTPS by setting the
506+
# `upgrade-insecure-requests` directive.
507+
#
508+
# Please note that `upgrade-insecure-requests` does not ensure
509+
# HTTPS for the top-level navigation. If you want to force the
510+
# website itself to be loaded over HTTPS you must include the
511+
# `Strict-Transport-Security` header.
512+
#
513+
# To make your CSP implementation easier, you can use an online CSP header
514+
# generator such as:
515+
# https://report-uri.com/home/generate/
516+
#
517+
# It is encouraged that you validate your CSP header using a CSP validator
518+
# such as:
519+
# https://csp-evaluator.withgoogle.com
520+
#
521+
# https://csp.withgoogle.com/docs/
474522
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
475-
# https://www.w3.org/TR/CSP3/
476-
# https://content-security-policy.com/
477523
# https://www.html5rocks.com/en/tutorials/security/content-security-policy/
524+
# https://www.w3.org/TR/CSP/
478525

479526
# <IfModule mod_headers.c>
480-
# Header set Content-Security-Policy "script-src 'self'; object-src 'self'" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
527+
# # (1) (2) (3) (4) (5)
528+
# Header set Content-Security-Policy "default-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
481529
# </IfModule>
482530

483531
# ----------------------------------------------------------------------
@@ -723,6 +771,7 @@ AddDefaultCharset utf-8
723771

724772
<IfModule mod_headers.c>
725773
Header unset X-Powered-By
774+
Header always unset X-Powered-By
726775
</IfModule>
727776

728777
# ----------------------------------------------------------------------

0 commit comments

Comments
 (0)