nginx returns html instead of json response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have configured the below settings in nginx after a few attempts by tweaking it. 

location /apis {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                fastcgi_intercept_errors off;
                add_header "X-Debug-JSON-APIS" $http_accept always;
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi.conf;
                fastcgi_param SCRIPT_FILENAME $document_root/index.php;
                 }

I have a follow up question related to the below error which appears in html instead of JSON format when I hit rest api calls http://mydomain.com/apis in case of when the MySQL Database service is down as part of testing the end to end flow. The flow is as follows:

User -> Nginx webserver -> PHP-FPM upstream server -> MySQL Database.

The Website Encountered an Unexpected Error. Please try again Later </br>

Is there a way to display the above string in JSON format?

Please guide me. Thanks in advance.

Best Regards,

Kaushal

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux