Answer the question
In order to leave comments, you need to log in
Setting up nginx, why is the request not being passed to php-fpm?
Good afternoon!
There is this config:
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
server_name tes.lc;
root /path/web;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
Answer the question
In order to leave comments, you need to log in
As for me, it's better to handle options by nginx itself, so as not to pull PHP once again
Instead of add_header 'Access-Control-Allow-Origin' "$http_origin"; in production, you need to hardcode the domain
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Origin,Accept';
add_header 'Content-Type' 'application/json';
add_header 'Content-Length' 0;
return 204;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question