nginx配置允许跨域访问

person smartzeng    watch_later 2017-06-05 10:07:03
visibility 1530    class nginx,配置,跨域,php    bookmark 分享

nginx配置允许跨域访问

location ~ .*\.(php|php5)?$
{
		
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type, Authorization';
    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
    if ($request_method = 'OPTIONS') {return 204;}
    #fastcgi_pass  unix:/tmp/php-cgi.sock;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi.conf;
}


评论区
评论列表
menu