跨域篇-nginx 反向代理跨域处理
1 连接上你的服务器找到你的nginx配置文件,一般在etc/nginx/nginx.conf
2 sudo vim nginx.conf 打开你的配置文件 找到 http 修改代码如下
http {
......
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
......
}
这样就可以实现GET,POST,OPTIONS的跨域请求的支持
也可以 add_header Access-Control-Allow-Origin http://www.testing.com; –指定允许的url;