Last active
February 28, 2020 15:37
-
-
Save iandmyhand/6490075eed2f54950e8172caa90bdd70 to your computer and use it in GitHub Desktop.
Allow cross origin list in Nginx.
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
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"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Referenced https://gist.github.com/Stanback/7145487