I have a header set in the main Apache (2.4.41 Ubuntu) config with a general CSP:
Header always set Content-Security-Policy "frame-ancestors 'self';"
I'm trying to override this for a specific website, in its virtual host:
<VirtualHost *:443>
ServerName example.com
DocumentRoot /var/www/example/app
ServerAdmin admin@example.com
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/certs/default.crt
SSLCertificateKeyFile /etc/apache2/ssl/private/default.key
Header always set Content-Security-Policy "frame-ancestors https://example2.com https://example3.com;"
</VirtualHost>
The virtual host header is ignored though. The HTTP response still returns the original header from the Apache config.
As an alternative, I tested overriding the header via the PHP app itself, but it simply adds a second duplicate header and the original Apache one still prevails.
Content-Security-Policy: frame-ancestors 'self';
Content-Security-Policy: frame-ancestors https://example2.com https://example3.com;