nginx 跨域解决

Posted F

tags:

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

server {

  listen 8811 default_server;

 

   root /opt/bp;

 

   # Make site accessible from http://localhost/

   server_name localhost;

 

   location / {

     if ( $request_method = OPTIONS ) { add_header Access-Control-Allow-Origin "$http_origin";add_header Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, DELETE";add_header Access-Control-Max-Age "3600";add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization";add_header Access-Control-Allow-Credentials "true";add_header Content-Length 0;add_header Content-Type text/plain;return 200;} add_header ‘Access-Control-Allow-Origin‘ ‘$http_origin‘;add_header ‘Access-Control-Allow-Credentials‘ ‘true‘;add_header ‘Access-Control-Allow-Methods‘ ‘GET, PUT, POST, DELETE, OPTIONS‘;add_header ‘Access-Control-Allow-Headers‘ ‘Content-Type,*‘;try_files $uri $uri/ =404;autoindex on;}

}

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

nginx 解决跨域、手机测试 2019-05-27

nginx配置反向代理解决vue跨域问题

宝塔面板Nginx反向代理解决跨域问题

Nginx----跨域,防盗链

nginx 解决AJAX 跨域问题。

Nginx解决跨域配置(Cors),支持白名单