跨域

server {
        listen 8080;
        # 全局(多个location路径)跨域
         if ($request_method = 'OPTIONS') {
             return 200;
         }
         add_header Access-Control-Allow-Origin *;
         add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
         add_header Access-Control-Allow-Headers *;

        location /hello {

            default_type text/html;
            content_by_lua '
                ngx.say("<p>hello, world !!!</p>")
            ';
        }
        location /uploadfile
        {  # 单个路径跨域配置
           #if ($request_method = 'OPTIONS') {
           #  add_header Access-Control-Allow-Origin *;
           #  add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
           #  add_header Access-Control-Allow-Headers *;
           #  return 200;
           #}
           #add_header Access-Control-Allow-Origin *;
           content_by_lua_file 'conf/lua/savefile.lua';
        }
    }