Welcome! Log In Create A New Profile

Advanced

Re: nginx returns html instead of json response

All files from this thread

File Name File Size   Posted by Date  
nginxtest.conf 3.6 KB open | download kaushalshriyan 11/07/2022 Read message
nginxtest.conf 3.6 KB open | download kaushalshriyan 11/08/2022 Read message
nginxtest.conf 3.6 KB open | download kaushalshriyan 11/09/2022 Read message
nginxtest.conf 3.6 KB open | download kaushalshriyan 11/14/2022 Read message
nginxtest.conf 3.6 KB open | download kaushalshriyan 11/22/2022 Read message
November 29, 2022 11:30AM
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

On Wed, Nov 23, 2022 at 11:39 PM Francis Daly <francis@daoine.org> wrote:

> On Wed, Nov 23, 2022 at 11:27:35PM +0530, Kaushal Shriyan wrote:
> > On Wed, Nov 23, 2022 at 11:20 PM Francis Daly <francis@daoine.org>
> wrote:
>
> Hi there,
>
> > I am not sure about this line error_page 555 /dummyfile; what does 555
> > code mean and what will be the contents of dummyfile?
> >
> > location ^~ /apis/ {
> > fastcgi_intercept_errors off;
> > error_page 555 /dummyfile;
> > fastcgi_pass 127.0.0.1:9000;
> > include fastcgi.conf;
> > fastcgi_param SCRIPT_FILENAME
> > /var/www/html/gsmaidp/web/index.php;
> > }
>
> I thought I had explained it in the previous mails?
>
> 555 is an error code that you do not care about (because you do not
> expect to see it).
>
> You can remove either the "error_page" or the "fastcgi_intercept_errors"
> line (or leave them both in).
>
> What happened when you tried it?
>
> f
> --
> Francis Daly francis@daoine.org
> _______________________________________________
> nginx mailing list -- nginx@nginx.org
> To unsubscribe send an email to nginx-leave@nginx.org
>
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

nginx returns html instead of json response

kaushalshriyan November 07, 2022 10:32AM

Re: nginx returns html instead of json response

Dan G. Switzer, II November 07, 2022 11:10AM

Re: nginx returns html instead of json response Attachments

kaushalshriyan November 07, 2022 12:48PM

Re: nginx returns html instead of json response

Dan G. Switzer, II November 07, 2022 01:22PM

Re: nginx returns html instead of json response

Maxim Dounin November 08, 2022 12:50AM

Re: nginx returns html instead of json response Attachments

kaushalshriyan November 08, 2022 02:56AM

Re: nginx returns html instead of json response Attachments

kaushalshriyan November 09, 2022 01:16PM

Re: nginx returns html instead of json response

Francis Daly November 11, 2022 04:08AM

Re: nginx returns html instead of json response

kaushalshriyan November 11, 2022 05:52AM

Re: nginx returns html instead of json response Attachments

kaushalshriyan November 14, 2022 09:56AM

Re: nginx returns html instead of json response

kaushalshriyan November 16, 2022 12:00PM

Re: nginx returns html instead of json response

Sergey A. Osokin November 16, 2022 04:42PM

Re: nginx returns html instead of json response

kaushalshriyan November 16, 2022 08:20PM

Re: nginx returns html instead of json response

Francis Daly November 17, 2022 12:28PM

Re: nginx returns html instead of json response

kaushalshriyan November 18, 2022 08:40AM

Re: nginx returns html instead of json response

Francis Daly November 18, 2022 11:06AM

Re: nginx returns html instead of json response

kaushalshriyan November 18, 2022 12:42PM

Re: nginx returns html instead of json response

Francis Daly November 18, 2022 01:32PM

Re: nginx returns html instead of json response

kaushalshriyan November 19, 2022 10:42AM

Re: nginx returns html instead of json response

Francis Daly November 21, 2022 02:22PM

Re: nginx returns html instead of json response Attachments

kaushalshriyan November 22, 2022 09:24AM

Re: nginx returns html instead of json response

Francis Daly November 23, 2022 12:50PM

Re: nginx returns html instead of json response

kaushalshriyan November 23, 2022 12:58PM

Re: nginx returns html instead of json response

Francis Daly November 23, 2022 01:10PM

Re: nginx returns html instead of json response

kaushalshriyan November 29, 2022 11:30AM

Re: nginx returns html instead of json response

kaushalshriyan November 30, 2022 12:48PM

Re: nginx returns html instead of json response

Francis Daly December 01, 2022 02:48PM

Re: nginx returns html instead of json response

kaushalshriyan November 23, 2022 12:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 329
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready