1
- # Apache Server Configs v4.1 .0 | MIT License
1
+ # Apache Server Configs v5.0 .0 | MIT License
2
2
# https://github.com/h5bp/server-configs-apache
3
3
4
4
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
27
27
# allowing access based on (sub)domain:
28
28
#
29
29
# 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.
30
33
31
34
# <IfModule mod_headers.c>
32
35
# Header set Access-Control-Allow-Origin "*"
36
+
37
+ # # (1)
38
+ # # Header append Vary Origin
33
39
# </IfModule>
34
40
35
41
# ----------------------------------------------------------------------
43
49
44
50
<IfModule mod_setenvif.c >
45
51
<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)$" >
47
53
SetEnvIf Origin ":" IS_CORS
48
54
Header set Access-Control-Allow -Origin "*" env=IS_CORS
49
55
</FilesMatch >
109
115
110
116
Options -MultiViews
111
117
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
-
138
118
# ######################################################################
139
119
# # MEDIA TYPES AND CHARACTER ENCODINGS #
140
120
# ######################################################################
@@ -183,6 +163,7 @@ Options -MultiViews
183
163
AddType image/avif avif
184
164
AddType image/avif-sequence avifs
185
165
AddType image/bmp bmp
166
+ AddType image/jxl jxl
186
167
AddType image/svg+xml svg svgz
187
168
AddType image/webp webp
188
169
AddType video/mp4 f4v f4p m4v mp4
@@ -453,8 +434,7 @@ AddDefaultCharset utf-8
453
434
#
454
435
# Keep in mind that while you could send the `X-Frame-Options` header for all
455
436
# 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.
458
438
#
459
439
# Nonetheless, you should ensure that you send the `X-Frame-Options` header for
460
440
# all pages that allow a user to make a state-changing operation (e.g: pages
@@ -465,10 +445,13 @@ AddDefaultCharset utf-8
465
445
# more than just clickjacking attacks.
466
446
# https://cure53.de/xfo-clickjacking.pdf.
467
447
#
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
+ #
469
451
# 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
472
455
473
456
# <IfModule mod_headers.c>
474
457
# Header always set X-Frame-Options "DENY" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
@@ -517,10 +500,17 @@ AddDefaultCharset utf-8
517
500
# The `frame-ancestors` directive helps avoid "Clickjacking" attacks and
518
501
# is similar to the `X-Frame-Options` header.
519
502
#
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
521
504
# `frame-ancestors` is also specified.
522
505
#
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
524
514
# as if they were loaded securely over HTTPS by setting the
525
515
# `upgrade-insecure-requests` directive.
526
516
#
@@ -529,7 +519,7 @@ AddDefaultCharset utf-8
529
519
# loaded over HTTPS you must include the `Strict-Transport-Security`
530
520
# header.
531
521
#
532
- # (6 ) The `Content-Security-Policy` header is included in all responses
522
+ # (7 ) The `Content-Security-Policy` header is included in all responses
533
523
# that are able to execute scripting. This includes the commonly used
534
524
# file types: HTML, XML and PDF documents. Although Javascript files
535
525
# can not execute script in a "browsing context", they are still included
@@ -544,14 +534,15 @@ AddDefaultCharset utf-8
544
534
# such as:
545
535
# https://csp-evaluator.withgoogle.com
546
536
#
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/
550
537
# 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/
551
542
552
543
# <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"
555
546
# </IfModule>
556
547
557
548
# ----------------------------------------------------------------------
@@ -644,9 +635,9 @@ AddDefaultCharset utf-8
644
635
# https://hstspreload.org/#deployment-recommendations
645
636
#
646
637
# https://tools.ietf.org/html/rfc6797#section-6.1
638
+ # https://owasp.org/www-project-secure-headers/#http-strict-transport-security
647
639
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
648
640
# https://www.html5rocks.com/en/tutorials/security/transport-layer-security/
649
- # https://blogs.msdn.microsoft.com/ieinternals/2014/08/18/strict-transport-security/
650
641
# https://hstspreload.org/
651
642
652
643
# <IfModule mod_headers.c>
@@ -666,6 +657,7 @@ AddDefaultCharset utf-8
666
657
# user-uploaded content or content that could potentially be treated as
667
658
# executable by the browser.
668
659
#
660
+ # https://owasp.org/www-project-secure-headers/#x-content-type-options
669
661
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
670
662
# https://blogs.msdn.microsoft.com/ie/2008/07/02/ie8-security-part-v-comprehensive-protection/
671
663
# https://mimesniff.spec.whatwg.org/
@@ -674,48 +666,6 @@ AddDefaultCharset utf-8
674
666
Header always set X-Content-Type-Options "nosniff"
675
667
</IfModule >
676
668
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
-
719
669
# ----------------------------------------------------------------------
720
670
# | Referrer Policy |
721
671
# ----------------------------------------------------------------------
@@ -735,14 +685,89 @@ AddDefaultCharset utf-8
735
685
# https://securityheaders.com/
736
686
# https://observatory.mozilla.org/
737
687
#
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
739
690
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
691
+ # https://scotthelme.co.uk/a-new-security-header-referrer-policy/
740
692
741
693
# <IfModule mod_headers.c>
742
694
# # (1)
743
695
# Header always set Referrer-Policy "strict-origin-when-cross-origin" "expr=%{CONTENT_TYPE} =~ m#text\/(css|html|javascript)|application\/pdf|xml#i"
744
696
# </IfModule>
745
697
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
+
746
771
# ----------------------------------------------------------------------
747
772
# | Disable TRACE HTTP Method |
748
773
# ----------------------------------------------------------------------
@@ -1138,6 +1163,7 @@ FileETag None
1138
1163
ExpiresByType image/bmp "access plus 1 month"
1139
1164
ExpiresByType image/gif "access plus 1 month"
1140
1165
ExpiresByType image/jpeg "access plus 1 month"
1166
+ ExpiresByType image/jxl "access plus 1 month"
1141
1167
ExpiresByType image/png "access plus 1 month"
1142
1168
ExpiresByType image/svg+xml "access plus 1 month"
1143
1169
ExpiresByType image/webp "access plus 1 month"
@@ -1230,6 +1256,6 @@ FileETag None
1230
1256
# <IfModule mod_rewrite.c>
1231
1257
# RewriteEngine On
1232
1258
# 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]
1234
1260
# </IfModule>
1235
1261
0 commit comments