Only set headers in apache if they don't exist
authorBastian Blank <waldi@debian.org>
Mon, 26 Mar 2018 18:48:08 +0000 (20:48 +0200)
committerBastian Blank <waldi@debian.org>
Mon, 26 Mar 2018 18:50:11 +0000 (20:50 +0200)
"Header always setifempty" does not work with proxied requests, as the
header from the response is added in the second header table.  This
means both tables want to set the headers.  The only way out seems to
check by hand if the header already exists somewhere.

Signed-off-by: Bastian Blank <waldi@debian.org>
modules/apache2/files/headers

index 15d3b08..89e6933 100644 (file)
@@ -1,9 +1,9 @@
 <IfModule mod_headers.c>
   Header set X-Clacks-Overhead "GNU Terry Pratchett"
 
-  Header always setifempty X-Content-Type-Options "nosniff"
-  Header always setifempty X-Frame-Options "sameorigin"
-  Header always setifempty Referrer-Policy "no-referrer"
-  # Header always setifempty X-Xss-Protection "1; mode=block"
-  Header always setifempty X-Xss-Protection "1"
+  Header always set X-Content-Type-Options "nosniff" "expr=-z %{resp:X-Content-Type-Options}"
+  Header always set X-Frame-Options "sameorigin" "expr=-z %{resp:X-Frame-Options}"
+  Header always set Referrer-Policy "no-referrer" "expr=-z %{resp:Referrer-Policy}"
+  # Header always set X-Xss-Protection "1; mode=block" "expr=-z %{resp:X-Xss-Protection}"
+  Header always set X-Xss-Protection "1" "expr=-z %{resp:X-Xss-Protection}"
 </IfModule>