Skip to content

Instantly share code, notes, and snippets.

@wkhayrattee
Last active April 18, 2017 15:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wkhayrattee/b7ca50a80409dceb05be6de3332b4ee7 to your computer and use it in GitHub Desktop.
Save wkhayrattee/b7ca50a80409dceb05be6de3332b4ee7 to your computer and use it in GitHub Desktop.
APACHE to NGINX | content-security-policy.conf
# REF: https://github.com/h5bp/server-configs-apache/blob/master/src/security/content-security-policy.conf
<IfModule mod_headers.c>
Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset Content-Security-Policy
</FilesMatch>
</IfModule>
# by default add some general content-security-policy
add_header Content-Security-Policy "object-src 'self'; script-src 'self'; report-uri 'https://a64f09869d9d888886f95be0f597d7ec.report-uri.io/r/default/csp/enforce' ";
# now unset Content-Security-Policy for resources matching all below
location ~* \.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$ {
more_clear_headers 'Content-Security-Policy';
}
@harikt
Copy link

harikt commented Apr 18, 2017

@wkhayrattee
Copy link
Author

thanks @harikt, the 2nd link I think is putting me on the track..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment