Nginx被调用方解决跨域问题

Nginx解决跨域

  1. 在nginx-xxx/conf目录下新建一个文件夹;
  2. 新建test.config;
  3. 在nginx.conf最后将test.conf引入:
     include vhost/*.config;
    

  4. 修改test.conf

    server {
     listen 8080;
     server_name wengdiquan.com;
    
     location /{
         proxy_pass     http://wengdiquan.vipgz1.idcfengye.com;
    
          add_header Access-Control-Allow-Credentials true;
          add_header Access-Control-Allow-Methods *;
    
          add_header Access-Control-Allow-Origin $http_origin;
          add_header Access-Control-Allow-Headers $http_access_control_request_headers;
          #
          if ($request_method = OPTIONS) {
              return 200;
          }
    
     }
    }
    
  5. nginx.exe -t测试通过后启动nginx
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页