Nginx 跨域
2016-06-27 12:10
369 查看
if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; # # Tell client that this pre-flight info is valid for 20 days # add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,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-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; } }
相关文章推荐
- centos6: mysql+nginx+php
- 从源码解析Nginx对 Native aio支持
- nginx php-fpm设置
- Linux 中 Nginx 重启关闭
- nginx安装篇
- nginx使用篇
- nginx+php_php-fpm编译版
- Nginx配置杂记
- complie and run nginx on ubuntu
- nginx配置yii2 URL重写规则
- Python的Flask框架及Nginx实现静态文件访问限制功能
- nginx下基于ThinkPHP框架的网站url重写
- nginx优化 突破十万并发
- Nginx应用实践入门
- Nginx之负载均衡
- centos7 安装nginx
- Unison(rpm方式)安装及应用--nginx高可用
- Nginx location 匹配规则
- nginx 的 rewrite 常用全局变量及规则
- Linux安装Nginx