CORS on nginx_cors cross-domain

Source: Internet
Author: User

Https://enable-cors.org/server_nginx.html


# # Wide-Open CORS config for Nginx # location/{if ($request _method = ' OPTIONS ') {add_header ' Access-cont
        Rol-allow-origin ' ' * ';
        Add_header ' Access-control-allow-methods ' Get, POST, OPTIONS '; # Custom headers and headers various browsers *should* is OK with but aren ' t # add_header ' Acces S-control-allow-headers ' Dnt,x-customheader,keep-alive,user-agent,x-requested-with,if-modified-since,
        Cache-control,content-type,content-range,range '; # Tell client, this, this pre-flight info is valid for the # Add_header ' Access-control-max-ag
        E ' 1728000; Add_header ' Content-type ' text/plain;
        Charset=utf-8 ';
        Add_header ' content-length ' 0;
     return 204;
        } if ($request _method = ' POST ') {add_header ' access-control-allow-origin ' *;
        Add_header ' Access-control-allow-methods ' Get, POST, OPTIONS '; Add_header ' Access-control-allow-headers ' Dnt,x-customheadeR,keep-alive,user-agent,x-requested-with,if-modified-since,cache-control,content-type,content-range,range '; Add_header ' Access-control-expose-headers ' Dnt,x-customheader,keep-alive,user-agent,x-requested-with,
     If-modified-since,cache-control,content-type,content-range,range ';
        } if ($request _method = ' get ') {add_header ' access-control-allow-origin ' *;
        Add_header ' Access-control-allow-methods ' Get, POST, OPTIONS '; Add_header ' Access-control-allow-headers ' Dnt,x-customheader,keep-alive,user-agent,x-requested-with,
        If-modified-since,cache-control,content-type,content-range,range '; Add_header ' Access-control-expose-headers ' Dnt,x-customheader,keep-alive,user-agent,x-requested-with,
     If-modified-since,cache-control,content-type,content-range,range '; }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.