nginx returns html instead of json response

Kaushal Shriyan kaushalshriyan at gmail.com
Wed Nov 30 17:45:40 UTC 2022


On Tue, Nov 29, 2022 at 9:58 PM Kaushal Shriyan <kaushalshriyan at gmail.com>
wrote:

> Hi Francis,
>
> Thanks a lot for all your help and support. It worked. I have configured
> the below settings in nginx after a few attempts by tweaking it. It worked
> like a charm.
>
> 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
>


Hi,

Checking in again if someone can help me with my earlier post to this
mailing list? Please guide me. Thanks in advance.

Best Regards,

Kaushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20221130/8057ee3f/attachment.htm>


More information about the nginx mailing list