Skip to content

Instantly share code, notes, and snippets.

@iandmyhand
Last active February 28, 2020 15:37
Show Gist options
  • Save iandmyhand/6490075eed2f54950e8172caa90bdd70 to your computer and use it in GitHub Desktop.
Save iandmyhand/6490075eed2f54950e8172caa90bdd70 to your computer and use it in GitHub Desktop.
Allow cross origin list in Nginx.
set $cors "";
if ($http_origin ~ '^(https)?\:\/\/(local\.)?(dev|www)\.(domain|seconddomain)\.com')) {
# if ($http_origin ~ '^(https)?\:\/\/([\w\d\.]*){2,}(domain|seconddomain)(\.co)?\.kr') {
set $cors "true";
}
location /test {
if ($cors = "true") {
add_header Access-Control-Allow-Origin "$http_origin";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type, Authorization";
add_header Access-Control-Allow-Credentials "true";
}
}
@iandmyhand
Copy link
Author

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