Home >Backend Development >PHP Tutorial >nginx configure ajax cross-domain access to php api

nginx configure ajax cross-domain access to php api

WBOY
WBOYOriginal
2016-08-08 09:32:551575browse

Open the nginx configuration file nginx.conf and configure it in the server:

location ~ .php?($|/)

{
#try_files $uri =404;
#handel cosr by mao
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'OPTION, POST, GET';
                                               add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type';
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;

}



The above introduces the nginx configuration of ajax cross-domain access to the php api, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP uses redisNext article:PHP uses redis