Skip to content

Instantly share code, notes, and snippets.

@Ry4an
Forked from alexjs/cors-nginx.conf
Last active November 5, 2020 07:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Ry4an/6195025 to your computer and use it in GitHub Desktop.
Save Ry4an/6195025 to your computer and use it in GitHub Desktop.
Here' the minimal Access-Control-Allow-Origin header insertion necessary to allow any whitelisted sites to access resources via CORS headers.
#
# Minimal CORS config for nginx
#
# A modification of https://gist.github.com/alexjs/4165271
#
# NB: This relies on the use of the 'Origin' HTTP Header.
location /static {
if ($http_origin ~* (whitelist\.address\.one|whitelist\.address\.two)$) {
add_header Access-Control-Allow-Origin "$http_origin";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment