Skip to content

Commit 8f7b2d4

Browse files
author
cristiano cardelli
committed
add security headers
1 parent ce7cdf3 commit 8f7b2d4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

build/docker/nginx/default.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ http {
1717
'"$http_user_agent" "$http_x_forwarded_for"';
1818
access_log /var/log/nginx/access.log main;
1919
add_header X-Frame-Options SAMEORIGIN;
20+
add_header X-Content-Type-Options nosniff;
21+
add_header X-XSS-Protection "1; mode=block";
22+
add_header Referrer-Policy "strict-origin-when-cross-origin";
23+
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()";
2024

2125
client_body_temp_path /var/cache/nginx/client_temp;
2226
proxy_temp_path /var/cache/nginx/proxy_temp;

config/wp-config.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,19 @@
133133
* More info at: https://docs.bitnami.com/general/apps/wordpress/troubleshooting/xmlrpc-and-pingback/
134134
*/
135135
if (!defined('WP_CLI')) {
136-
// remove x-pingback HTTP header
136+
// remove x-pingback and add security headers
137137
add_filter("wp_headers", function ($headers) {
138138
unset($headers["X-Pingback"]);
139+
140+
$headers["X-Content-Type-Options"] = "nosniff";
141+
$headers["X-XSS-Protection"] = "1; mode=block";
142+
$headers["Referrer-Policy"] = "strict-origin-when-cross-origin";
143+
$headers["Permissions-Policy"] = "geolocation=(), microphone=(), camera=()";
144+
145+
if (function_exists("is_ssl") && is_ssl()) {
146+
$headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains";
147+
}
148+
139149
return $headers;
140150
});
141151
// disable pingbacks

0 commit comments

Comments
 (0)