码迷,mamicode.com
首页 > 其他好文 > 详细

nginx跨域处理

时间:2016-01-20 19:21:30      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

http://www.nginx.cn/nginx-download

nginx.conf配置

if ($request_method = ‘OPTIONS’) { 
        add_header Access-Control-Allow-Origin *; 
        add_header Access-Control-Allow-Credentials true; 
        add_header Access-Control-Allow-Methods ‘GET, POST, OPTIONS’; 
        add_header ‘Access-Control-Allow-Headers’ ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type’; 
        return 200; 
    } 
     if ($request_method = ‘POST’) {

        add_header ‘Access-Control-Allow-Origin’ *; 
        add_header ‘Access-Control-Allow-Credentials’ ‘true’; 
        add_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS’; 
        add_header ‘Access-Control-Allow-Headers’ ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type’;

     }

     if ($request_method = ‘GET’) {

        add_header ‘Access-Control-Allow-Origin’ *; 
        add_header ‘Access-Control-Allow-Credentials’ ‘true’; 
        add_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS’; 
        add_header ‘Access-Control-Allow-Headers’ ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type’;

     }

nginx跨域处理

标签:

原文地址:http://www.cnblogs.com/adolfmc/p/5146149.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!