Answer the question
In order to leave comments, you need to log in
How to display JSON with response code 200 in NGINX on time-out?
Hello! There is a bunch of NGINX - php-fpm. I need that when the script hangs for more than 2 seconds, json is output with a response code of 200. I did the Json output, but I can’t change the code :( it always shows 504. How can this be done?
nginx config:
#Errors
error_page 504 /errors_json/index.php?504;
location = /errors_json/index.php {
root "/var/www/site/releases/public";
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
internal;
}
header( 'HTTP/1.1 200 OK' );
header('Content-Type: application/json');
$data = [
'text' => 'Слишком долго думаю, повторите'
];
echo json_encode($data);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question