nginx配置允许跨域访问


nginx配置允许跨域访问

1
2
3
4
5
6
7
8
9
10
11
12
13
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;
}