您的位置:首页 > 运维架构 > Nginx

nginx配置允许跨域访问

2017-10-27 09:41 841 查看
1、对外提供的查询订单信息接口需要支持跨域访问:

if ($http_origin ~* ((http|https)?://.*\.aa\.(com|hk)$)) {
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type';
}2、nginx配置请求转到https
if ($http_x_proto != SSL) {
rewrite ^(.*)$ https://$host$1 permanent;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: