-
-
Save wstam88/c86bc9e4e9e70d56fcc2abd1d228f6ce to your computer and use it in GitHub Desktop.
Nginx CORS and CSP configuration for wildcard origin domains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
... | |
add_header Content-Security-Policy "default-src 'none'"; | |
add_header X-Content-Security-Policy "default-src 'none'"; | |
add_header X-WebKit-CSP "default-src 'none'"; | |
add_header "Access-Control-Allow-Headers" "X-Requested-With"; | |
if ( $http_origin ~* (https?://(.+\.)?(domain1|domain2|domain3)\.(?:me|co|com)$) ) { | |
set $cors "$http_origin"; | |
} | |
add_header "Access-Control-Allow-Origin" "$cors"; | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment