Вопрос

I added the following lines to my .htacces file:

Content-Security-Policy: default-src 'self'
X-Content-Security-Policy: default-src 'self'
X-WebKit-CSP: default-src 'self'

But I always got the following error:

Invalid command 'Content-Security-Policy:', perhaps misspelled or defined by a module not included in the server configuration

I don't get it. Which Apache module do I have to activate? What's wrong with these lines?

Thx, David

Это было полезно?

Решение 2

I'm not an apache expert, but content security policy is a response header. http://httpd.apache.org/docs/2.2/mod/mod_headers.html

Другие советы

Add those lines into your httpd.conf configuration files, or inside your virtualhost sections, or inside your .htaccess files:

Header unset Content-Security-Policy
Header add Content-Security-Policy "default-src 'self'"
Header unset X-Content-Security-Policy
Header add X-Content-Security-Policy "default-src 'self'"
Header unset X-WebKit-CSP
Header add X-WebKit-CSP "default-src 'self'"

You may also be interested in adding those headers:

Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
Header set X-Frame-Options "DENY"
Header set Strict-Transport-Security "max-age=631138519; includeSubDomains"

You have to enable (LoadModule) mod_headers if not already enabled, then restart apache.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top