http {
...
map $http_referer $allow_cors {
default 1;
"~^https?://www1\.theorydance\.com.*$" 1;
"~*" 0;
}
server {
location / {
if ($allow_cors = 0){
return 403;
}
root /data/deploy;
}
}
}
可以根据$http_orgin
进行判断
map $http_orgin $allow_cros {
default 1;
"~^(https?://(localhost)(:[0-9]+)?)$" 1;
"~*" 0;
}