nginx 配置跨域

Posted jasonbourne3

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx 配置跨域相关的知识,希望对你有一定的参考价值。

 location / {
        add_header Access-Control-Allow-Origin *;
                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,Authorization;
               if ($request_method = OPTIONS) {
                    return 204;
    }
        proxy_pass http://localhost:60877/;
            root   html;
            index  index.html index.htm;
        }            

 

以上是关于nginx 配置跨域的主要内容,如果未能解决你的问题,请参考以下文章

nginx跨域配置

nginx配置跨域gzip加速代理详细讲解

nginx配置解决前端跨域问题

使用Nginx来解决跨域的问题

Nginx前后端跨域

Nginx前后端跨域