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;
                }
                 
               
        }

 

Centos+nginx站点设置允许跨域
https://fanly.net/article/bMjkufZmFm
转载请注明出处,谢谢!