nginx配置跨域访问

前端要在本地测试ajax接口,无法跨域访问,所以在测试环境的nginx配置了跨域支持,方法如下:

在nginx.conf文件, http块下配置

42 #support cross domain access
43 add_header Access-Control-Allow-Origin *;
44 add_header Access-Control-Allow-Headers X-Requested-With;
45 add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

 

posted @ 2015-08-11 10:58  JinleiZhang  阅读(1821)  评论(0编辑  收藏  举报