1- # Apache Server Configs v4.1 .0 | MIT License
1+ # Apache Server Configs v5.0 .0 | MIT License
22# https://github.com/h5bp/server-configs-apache
33
44# (!) Using `.htaccess` files slows down Apache, therefore, if you have
2727# allowing access based on (sub)domain:
2828#
2929# Header set Access-Control-Allow-Origin "subdomain.example.com"
30+ #
31+ # (1) When `Access-Control-Allow-Origin` points to a specific rule rather
32+ # than `*`, then `Vary: Origin` should be sent along with the response.
3033
3134# <IfModule mod_headers.c>
3235# Header set Access-Control-Allow-Origin "*"
36+
37+ # # (1)
38+ # # Header append Vary Origin
3339# </IfModule>
3440
3541# ----------------------------------------------------------------------
4349
4450<IfModule mod_setenvif.c >
4551 <IfModule mod_headers.c >
46- <FilesMatch "\.(avifs?|bmp|cur|gif|ico|jpe?g|a?png|svgz?|webp)$" >
52+ <FilesMatch "\.(avifs?|bmp|cur|gif|ico|jpe?g|jxl| a?png|svgz?|webp)$" >
4753 SetEnvIf Origin ":" IS_CORS
4854 Header set Access-Control-Allow -Origin "*" env=IS_CORS
4955 </FilesMatch >
109115
110116Options -MultiViews
111117
112- # ######################################################################
113- # # INTERNET EXPLORER #
114- # ######################################################################
115-
116- # ----------------------------------------------------------------------
117- # | Document modes |
118- # ----------------------------------------------------------------------
119-
120- # Force Internet Explorer 8/9/10 to render pages in the highest mode
121- # available in various cases when it may not.
122- #
123- # https://hsivonen.fi/doctype/#ie8
124- #
125- # (!) Starting with Internet Explorer 11, document modes are deprecated.
126- # If your business still relies on older web apps and services that were
127- # designed for older versions of Internet Explorer, you might want to
128- # consider enabling `Enterprise Mode` throughout your company.
129- #
130- # https://msdn.microsoft.com/en-us/library/ie/bg182625.aspx#docmode
131- # https://blogs.msdn.microsoft.com/ie/2014/04/02/stay-up-to-date-with-enterprise-mode-for-internet-explorer-11/
132- # https://msdn.microsoft.com/en-us/library/ff955275.aspx
133-
134- <IfModule mod_headers.c >
135- Header always set X-UA-Compatible "IE=edge" "expr=%{CONTENT_TYPE } =~ m#text/html#i"
136- </IfModule >
137-
138118# ######################################################################
139119# # MEDIA TYPES AND CHARACTER ENCODINGS #
140120# ######################################################################
@@ -183,6 +163,7 @@ Options -MultiViews
183163 AddType image/avif avif
184164 AddType image/avif-sequence avifs
185165 AddType image/bmp bmp
166+ AddType image/jxl jxl
186167 AddType image/svg+xml svg svgz
187168 AddType image/webp webp
188169 AddType video/mp4 f4v f4p m4v mp4
@@ -453,8 +434,7 @@ AddDefaultCharset utf-8
453434#
454435# Keep in mind that while you could send the `X-Frame-Options` header for all
455436# of your website's pages, this has the potential downside that it forbids even
456- # non-malicious framing of your content (e.g.: when users visit your website
457- # using a Google Image Search results page).
437+ # non-malicious framing of your content.
458438#
459439# Nonetheless, you should ensure that you send the `X-Frame-Options` header for
460440# all pages that allow a user to make a state-changing operation (e.g: pages
@@ -465,10 +445,13 @@ AddDefaultCharset utf-8
465445# more than just clickjacking attacks.
466446# https://cure53.de/xfo-clickjacking.pdf.
467447#
468- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
448+ # (!) The `Content-Security-Policy` header has a `frame-ancestors` directive
449+ # which obsoletes this header for supporting browsers.
450+ #
469451# https://tools.ietf.org/html/rfc7034
470- # https://blogs.msdn.microsoft.com/ieinternals/2010/03/30/combating-clickjacking-with-x-frame-options/
471- # https://www.owasp.org/index.php/Clickjacking
452+ # https://owasp.org/www-project-secure-headers/#x-frame-options
453+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
454+ # https://docs.microsoft.com/archive/blogs/ieinternals/combating-clickjacking-with-x-frame-options
472455
473456# <IfModule mod_headers.c>
474457# Header always set X-Frame-Options "DENY" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
@@ -517,10 +500,17 @@ AddDefaultCharset utf-8
517500# The `frame-ancestors` directive helps avoid "Clickjacking" attacks and
518501# is similar to the `X-Frame-Options` header.
519502#
520- # Browsers that support the CSP header will ignore `X-Frame-Options` if
503+ # Browsers that support the CSP header should ignore `X-Frame-Options` if
521504# `frame-ancestors` is also specified.
522505#
523- # (5) Forces the browser to treat all the resources that are served over HTTP
506+ # (5) Elements controlled by `object-src` are perhaps coincidentally
507+ # considered legacy HTML elements and are not receiving new standardized
508+ # features (such as the security attributes `sandbox` or `allow` for
509+ # `<iframe>`).
510+ # Therefore it is recommended to restrict this fetch-directive (e.g.,
511+ # explicitly set `object-src 'none'` if possible).
512+ #
513+ # (6) Forces the browser to treat all the resources that are served over HTTP
524514# as if they were loaded securely over HTTPS by setting the
525515# `upgrade-insecure-requests` directive.
526516#
@@ -529,7 +519,7 @@ AddDefaultCharset utf-8
529519# loaded over HTTPS you must include the `Strict-Transport-Security`
530520# header.
531521#
532- # (6 ) The `Content-Security-Policy` header is included in all responses
522+ # (7 ) The `Content-Security-Policy` header is included in all responses
533523# that are able to execute scripting. This includes the commonly used
534524# file types: HTML, XML and PDF documents. Although Javascript files
535525# can not execute script in a "browsing context", they are still included
@@ -544,14 +534,15 @@ AddDefaultCharset utf-8
544534# such as:
545535# https://csp-evaluator.withgoogle.com
546536#
547- # https://csp.withgoogle.com/docs/
548- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
549- # https://www.html5rocks.com/en/tutorials/security/content-security-policy/
550537# https://www.w3.org/TR/CSP/
538+ # https://owasp.org/www-project-secure-headers/#content-security-policy
539+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
540+ # https://developers.google.com/web/fundamentals/security/csp
541+ # https://content-security-policy.com/
551542
552543# <IfModule mod_headers.c>
553- # # (1) (2) (3) (4) (5) (6 )
554- # Header always 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|javascript)|application\/pdf|xml#i"
544+ # # (1) (2) (3) (4) (5) (6) (7 )
545+ # Header always set Content-Security-Policy "default-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; object-src 'none'; upgrade-insecure-requests" "expr=%{CONTENT_TYPE} =~ m#text\/(html|javascript)|application\/pdf|xml#i"
555546# </IfModule>
556547
557548# ----------------------------------------------------------------------
@@ -644,9 +635,9 @@ AddDefaultCharset utf-8
644635# https://hstspreload.org/#deployment-recommendations
645636#
646637# https://tools.ietf.org/html/rfc6797#section-6.1
638+ # https://owasp.org/www-project-secure-headers/#http-strict-transport-security
647639# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
648640# https://www.html5rocks.com/en/tutorials/security/transport-layer-security/
649- # https://blogs.msdn.microsoft.com/ieinternals/2014/08/18/strict-transport-security/
650641# https://hstspreload.org/
651642
652643# <IfModule mod_headers.c>
@@ -666,6 +657,7 @@ AddDefaultCharset utf-8
666657# user-uploaded content or content that could potentially be treated as
667658# executable by the browser.
668659#
660+ # https://owasp.org/www-project-secure-headers/#x-content-type-options
669661# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
670662# https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-v-comprehensive-protection/
671663# https://mimesniff.spec.whatwg.org/
@@ -674,48 +666,6 @@ AddDefaultCharset utf-8
674666 Header always set X-Content-Type-Options "nosniff"
675667</IfModule >
676668
677- # ----------------------------------------------------------------------
678- # | Cross-Site Scripting (XSS) Protection |
679- # ----------------------------------------------------------------------
680-
681- # Protect website reflected Cross-Site Scripting (XSS) attacks.
682- #
683- # (1) Try to re-enable the cross-site scripting (XSS) filter built into most
684- # web browsers.
685- #
686- # The filter is usually enabled by default, but in some cases, it may be
687- # disabled by the user. However, in Internet Explorer, for example, it can
688- # be re-enabled just by sending the `X-XSS-Protection` header with the
689- # value of `1`.
690- #
691- # (2) Prevent web browsers from rendering the web page if a potential reflected
692- # (a.k.a non-persistent) XSS attack is detected by the filter.
693- #
694- # By default, if the filter is enabled and browsers detect a reflected XSS
695- # attack, they will attempt to block the attack by making the smallest
696- # possible modifications to the returned web page.
697- #
698- # Unfortunately, in some browsers (e.g.: Internet Explorer), this default
699- # behavior may allow the XSS filter to be exploited. Therefore, it's better
700- # to inform browsers to prevent the rendering of the page altogether,
701- # instead of attempting to modify it.
702- #
703- # https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities
704- #
705- # (!) Do not rely on the XSS filter to prevent XSS attacks! Ensure that you are
706- # taking all possible measures to prevent XSS attacks, the most obvious
707- # being: validating and sanitizing your website's inputs.
708- #
709- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
710- # https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-iv-the-xss-filter/
711- # https://blogs.msdn.microsoft.com/ieinternals/2011/01/31/controlling-the-xss-filter/
712- # https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
713-
714- # <IfModule mod_headers.c>
715- # # (1) (2)
716- # Header always set X-XSS-Protection "1; mode=block" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
717- # </IfModule>
718-
719669# ----------------------------------------------------------------------
720670# | Referrer Policy |
721671# ----------------------------------------------------------------------
@@ -735,14 +685,89 @@ AddDefaultCharset utf-8
735685# https://securityheaders.com/
736686# https://observatory.mozilla.org/
737687#
738- # https://scotthelme.co.uk/a-new-security-header-referrer-policy/
688+ # https://www.w3.org/TR/referrer-policy/
689+ # https://owasp.org/www-project-secure-headers/#referrer-policy
739690# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
691+ # https://scotthelme.co.uk/a-new-security-header-referrer-policy/
740692
741693# <IfModule mod_headers.c>
742694# # (1)
743695# Header always set Referrer-Policy "strict-origin-when-cross-origin" "expr=%{CONTENT_TYPE} =~ m#text\/(css|html|javascript)|application\/pdf|xml#i"
744696# </IfModule>
745697
698+ # ----------------------------------------------------------------------
699+ # | Cross Origin Policy |
700+ # ----------------------------------------------------------------------
701+
702+ # Set strict a Cross Origin Policy to mitigate information leakage.
703+ #
704+ # (1) Cross-Origin-Embedder-Policy prevents a document from loading any
705+ # cross-origin resources that don’t explicitly grant the document
706+ # permission.
707+ # https://html.spec.whatwg.org/multipage/origin.html#coep
708+ # https://owasp.org/www-project-secure-headers/#cross-origin-embedder-policy
709+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy
710+ #
711+ # (2) Cross-Origin-Opener-Policy allows you to ensure a top-level document does
712+ # not share a browsing context group with cross-origin documents.
713+ # https://html.spec.whatwg.org/multipage/origin.html#cross-origin-opener-policies
714+ # https://owasp.org/www-project-secure-headers/#cross-origin-opener-policy
715+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy
716+ #
717+ # (3) Cross-Origin-Resource-Policy allows to define a policy that lets web
718+ # sites and applications opt in to protection against certain requests from
719+ # other origins, to mitigate speculative side-channel attacks.
720+ # https://fetch.spec.whatwg.org/#cross-origin-resource-policy-header
721+ # https://owasp.org/www-project-secure-headers/#cross-origin-resource-policy
722+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy
723+ # https://resourcepolicy.fyi/
724+ #
725+ # To check your Cross Origin Policy, you can use an online service, such as:
726+ # https://securityheaders.com/
727+ # https://observatory.mozilla.org/
728+ #
729+ # https://web.dev/coop-coep/
730+ # https://web.dev/why-coop-coep/
731+ # https://web.dev/cross-origin-isolation-guide/
732+ # https://scotthelme.co.uk/coop-and-coep/
733+
734+ # <IfModule mod_headers.c>
735+ # # (1)
736+ # Header always set Cross-Origin-Embedder-Policy "require-corp" "expr=%{CONTENT_TYPE} =~ m#text\/(html|javascript)|application\/pdf|xml#i"
737+
738+ # # (2)
739+ # Header always set Cross-Origin-Opener-Policy "same-origin" "expr=%{CONTENT_TYPE} =~ m#text\/(html|javascript)|application\/pdf|xml#i"
740+
741+ # # (3)
742+ # Header always set Cross-Origin-Resource-Policy "same-origin" "expr=%{CONTENT_TYPE} =~ m#text\/(html|javascript)|application\/pdf|xml#i"
743+ # </IfModule>
744+
745+ # ----------------------------------------------------------------------
746+ # | Permissions Policy |
747+ # ----------------------------------------------------------------------
748+
749+ # Set a strict Permissions Policy to mitigate access to browser features.
750+ #
751+ # The header uses a structured syntax, and allows sites to more tightly
752+ # restrict which origins can be granted access to features.
753+ # The list of available features: https://github.com/w3c/webappsec-permissions-policy/blob/main/features.md
754+ #
755+ # The example policy below aims to disable all features expect synchronous
756+ # `XMLHttpRequest` requests on the same origin.
757+ #
758+ # To check your Permissions Policy, you can use an online service, such as:
759+ # https://securityheaders.com/
760+ # https://observatory.mozilla.org/
761+ #
762+ # https://www.w3.org/TR/permissions-policy-1/
763+ # https://owasp.org/www-project-secure-headers/#permissions-policy
764+ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
765+ # https://scotthelme.co.uk/a-new-security-header-feature-policy/
766+
767+ # <IfModule mod_headers.c>
768+ # Header always set Permissions-Policy "accelerometer=(),autoplay=(),camera=(),display-capture=(),document-domain=(),encrypted-media=(),fullscreen=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),publickey-credentials-get=(),screen-wake-lock=(),sync-xhr=(self),usb=(),web-share=(),xr-spatial-tracking=()" "expr=%{CONTENT_TYPE} =~ m#text\/(html|javascript)|application\/pdf|xml#i"
769+ # </IfModule>
770+
746771# ----------------------------------------------------------------------
747772# | Disable TRACE HTTP Method |
748773# ----------------------------------------------------------------------
@@ -1138,6 +1163,7 @@ FileETag None
11381163 ExpiresByType image/bmp "access plus 1 month"
11391164 ExpiresByType image/gif "access plus 1 month"
11401165 ExpiresByType image/jpeg "access plus 1 month"
1166+ ExpiresByType image/jxl "access plus 1 month"
11411167 ExpiresByType image/png "access plus 1 month"
11421168 ExpiresByType image/svg+xml "access plus 1 month"
11431169 ExpiresByType image/webp "access plus 1 month"
@@ -1230,6 +1256,6 @@ FileETag None
12301256# <IfModule mod_rewrite.c>
12311257# RewriteEngine On
12321258# RewriteCond %{REQUEST_FILENAME} !-f
1233- # RewriteRule ^(.+)\.(\w+)\.(avifs?|bmp|css|cur|gif|ico|jpe?g|m?js|a?png|svgz?|webp|webmanifest)$ $1.$3 [L]
1259+ # RewriteRule ^(.+)\.(\w+)\.(avifs?|bmp|css|cur|gif|ico|jpe?g|jxl| m?js|a?png|svgz?|webp|webmanifest)$ $1.$3 [L]
12341260# </IfModule>
12351261
0 commit comments