zoukankan      html  css  js  c++  java
  • Nginx *解决跨域问题

    server {
        listen       8080;
        server_name  localhost;
        
        location / {
            proxy_pass http://111.111.111.111:8080;  # 代理的地址
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            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;
            }
            # root   html;
            # index  index.html index.htm;
        }
    }
    
    

    如果请求部分资源错误,报如下错:

    upstream sent invalid chunked response while reading upstream,

    那么加上 proxy_http_version 1.1; proxy_set_header Connection "";

  • 相关阅读:
    严格模式
    排序,求最大值最小值
    原型继承
    android 系统
    BASE64Decoder
    jstl
    list  遍历
    2015GitWebRTC编译实录9
    2015GitWebRTC编译实录8
    2015GitWebRTC编译实录7
  • 原文地址:https://www.cnblogs.com/ingen42/p/12941774.html
Copyright © 2011-2022 走看看