Examples:

# Apache in .htaccess or httpd: The always directive in Apache ensures that a header is set even for error responses.
Header always set X-Xss-Protection "1; mode=block"
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
Header always set X-Content-Type-Options nosniff
Header always set Referrer-Policy same-origin
Header always set X-Frame-Options SAMEORIGIN

# and add customer specific:
Header always set Content-Security-Policy "default-src 'none'; base-uri 'none'; frame-src 'self'; connect-src 'self'; form-action 'self'; font-src 'self' data: https://fonts.googleapis.com https://fonts.gstatic.com; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; style-src 'unsafe-inline' 'self' data:; style-src-elem 'self' 'unsafe-inline' data: https://fonts.googleapis.com;"

Header always set Permissions-Policy geolocation=()

# Nginx: By default, Nginx only sets headers for successful responses (2xx, 3xx).
add_header X-Xss-Protection "1; mode=block" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy same-origin always;
add_header X-Frame-Options SAMEORIGIN always;

# and add customer specific:
add_header Content-Security-Policy "default-src 'none'; base-uri 'none'; frame-src 'self'; connect-src 'self'; form-action 'self'; font-src 'self' data: https://fonts.googleapis.com https://fonts.gstatic.com; frame-ancestors 'self'; img-src 'self' data:; object-src 'none'; script-src 'self'; style-src 'unsafe-inline' 'self' data:; style-src-elem 'self' 'unsafe-inline' data: https://fonts.googleapis.com;" always;
add_header Permissions-Policy geolocation=() always;

#Notes:
# - Having an external frame-ancestor in CSP: X-Frame-Options SAMEORIGIN works
# - Chrome using F12 shows problems in yellow an red to fix.

Practical use:
– The file .htaccess just works well for Apache without restart of the web server;
– Having Nginx in front, use of .htaccess may reduce performance;
– In DirectAdmin additional httpd configuration and afterward reload of httpd/Apache
(restart would kill web sessions);
– In Plesk additional apache/nginx configuration does immediately kill websessions by restart web sessions for all domains after each change for one of the domains;
– Ctrl-F5 clears cache in Chrome of a page plus Content Security Policy of that page;
– Caching by web browsers can be avoided in the header section of each web page:
see

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">

Check and read explanation:
https://securityheaders.com
https://observatory.mozilla.org
Note: learn from other sites. And F12 for messages in red in the webbrowser.

Security header plugin for WordPress:
A plugin, however intended well, causes set up to become out of control: WP Content Security Policy Plugin

Evaluate for coming Content Security Policy:
https://csp-evaluator.withgoogle.com

Advanced checking:
https://www.immuniweb.com/ssl/