ngxin静态资源配置跨域

asp.netcore api两种方式可以设置静态资源跨域,ngxinx代理可以设置,startup配置文件中也可以设置
以下是nginx的静态资源cors跨域设置方法
 
server { 

listen 80; 
server_name xxx.domain.com; 
 
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $remote_addr; 
proxy_set_header X-Forwarded-Proto $scheme;
 
location / { 
proxy_next_upstream http_502 http_504 error timeout invalid_header ; 
}
 
location /images { 
proxy_next_upstream http_502 http_504 error timeout invalid_header ; 
 
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Allow-Credentials' "true"; 
add_header Access-Control-Allow-Headers X-Requested-With;
}
}

posted on 2020-05-31 00:07  willhuo  阅读(861)  评论(0编辑  收藏  举报