Posted in Servers onMarch 09, 2021
set $cors_origin "";
if ($http_origin ~* "^https://www.abc.com$") {
set $cors_origin $http_origin;
}
if ($http_origin ~* "^https://abc.com$") {
set $cors_origin $http_origin;
}
if ($http_origin ~* "^https://www.abc.cn$") {
set $cors_origin $http_origin;
}
if ($http_origin ~* "^https://abc.cn$") {
set $cors_origin $http_origin;
}
add_header Access-Control-Allow-Origin $cors_origin;
location / {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin $cors_origin;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
return 404;
}
}
nginx 设置多个站跨域
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@