nginx配置允许跨域访问

来源:互联网 发布:mysql北京时间转unix 编辑:程序博客网 时间:2024/05/22 03:35

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;}



原创粉丝点击