nginx.conf,如下:
其中 Access-Control-Allow-Origin 是header 名字 "." 是对应的value
server {
listen 80 default_server;
add_header Access-Control-Allow-Origin '*' ;
listen [::]:80 default_server;
root /root/mnt/bimatrix_fs;
index index.html index.htm index.nginx-debian.html;
server_name localhost;
location / {
add_header Access-Control-Allow-Origin '*' ;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}

本文介绍了一个具体的Nginx配置案例,展示了如何通过设置Access-Control-Allow-Origin头部来实现跨域资源共享(CORS)。该配置允许从任意源发起的请求访问服务器资源。
3921

被折叠的 条评论
为什么被折叠?



