美文网首页
nginx 跨域配置

nginx 跨域配置

作者: 夜雨声烦人 | 来源:发表于2019-10-19 08:54 被阅读0次
   if ($request_method = 'OPTIONS') {
            add_header Access-Control-Allow-Origin $http_origin;
            add_header Access-Control-Max-Age 3600;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
            add_header Access-Control-Allow-Headers 'Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
            add_header 'Access-Control-Allow-Credentials' true;
            add_header Content-Length 0;
            return 204;
    }

    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_pass   http://127.0.0.1:8080;

相关文章

网友评论

      本文标题:nginx 跨域配置

      本文链接:https://www.haomeiwen.com/subject/hysgmctx.html