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 16, 2022 12:00PM
On Mon, Nov 14, 2022 at 8:24 PM Kaushal Shriyan <kaushalshriyan@gmail.com>
wrote:

>
>
>> On Fri, Nov 11, 2022 at 2:38 PM Francis Daly <francis@daoine.org> wrote:
>>
>>> On Wed, Nov 09, 2022 at 11:45:20PM +0530, Kaushal Shriyan wrote:
>>>
>>> Hi there,
>>>
>>> > Checking in again if someone can help me with my earlier post to this
>>> > mailing list?
>>>
>>> The question in the post was, and is, a bit unclear to me.
>>>
>>> You seem to be showing multiple different requests, so I'm not sure
>>> exactly what you are asking.
>>>
>>> Maybe it is also unclear to others? In that case,it may be useful if
>>> you can simplify your example question?
>>>
>>> > I have a follow up question, when the user invokes ->
>>> > http://mydomain.com/apis http://mydomain.com/api/v1/* -> Nginx
>>> Webserver
>>> > -> Drupal 9 Core CMS -> PHP-FPM backend server.
>>> >
>>> > Nginx should present the below info on 500 ISE error conditions for
>>> /apis
>>> > and /apis/* The below message sends back the response to Nginx web
>>> server
>>> > to render it to the client browser instead of the /error-500.html file
>>> > contents.
>>> >
>>> > "type" => "/problems/API-saving-error",
>>> > "title" => $this->t("Issue occured while saving the
>>> > API."),
>>> > "detail" => $this->t("There are some wrong inputs
>>> passed
>>> > to DB which caused this issue."),
>>>
>>> What one specific request do you want to make? (Maybe
>>> http://mydomain.com/apis, maybe http://mydomain.com/api/v1/*, maybe
>>> http://mydomain.com/api/v1/example, maybe something else?)
>>>
>>> For that one specific request, what do you want nginx to do with
>>> it? (Maybe make a http request to the Drupal system? Or a fastcgi request
>>> to the Drupal system? Or handle it internally withint nginx?)
>>>
>>> For the response from that request, what do you want nginx to do with
>>> it? (Send it to the user as-is? Mangle / modify it somehow? If so --
>>> how? Change the http response code or headers? Change the response body?)
>>>
>>>
>>> I suspect that if you can describe what exactly you want nginx to do,
>>> someone will have a better chance of sharing how to configure nginx to
>>> do that thing.
>>>
>>> > I have the below settings in nginx conf file
>>> >
>>> > error_page 500 /error-500.html;
>>> > location = /error-500.html {
>>> > root
>>> >
>>> /var/www/html/gsmamarketplace/web/servererrorpages/error-pages-500-503/html;
>>> > }
>>>
>>> For example: the above stanza says "if nginx is going to
>>> send a http 500 response, it should send the contents of the file
>>>
>>> /var/www/html/gsmamarketplace/web/servererrorpages/error-pages-500-503/html/error-500.html
>>> as the response body", along with the http 500 response header.
>>>
>>> If that is what you want nginx to do, the configuration is correct. If
>>> it is not, it is not.
>>>
>>> > I am trying to set the below location and try_files directive block in
>>> > nginx.conf file
>>> > location /apis {
>>> > try_files $uri $uri/ /path/to/api/handler; (This part is
>>> not
>>> > clear with me)
>>> > }
>>>
>>> And I can see what this nginx config will do; but I do not know what you
>>> want it to do. If you can give the full details for one example request,
>>> then maybe it will become clear to me. (And maybe others will be able
>>> to help too, if they are similarly confused.)
>>>
>>> Thanks,
>>>
>>> f
>>> --
>>> Francis Daly francis@daoine.org
>>> _______________________________________________
>>> nginx mailing list -- nginx@nginx.org
>>> To unsubscribe send an email to nginx-leave@nginx.org
>>
>>
> Hi,
>
> We have a Drupal site and for this Drupal site we are showing customized
> HTML pages if any 500 errors occurred in the site. This customized 500 html
> error page is configured at Nginx server, so that whenever any 500 error
> occurs on site, Nginx presents that HTML page.
>
> Now , we don’t want that HTML error page for all the cases even if there
> 500 errors occurred, instead we need a JSON response. For example
> https://mydrupalsite.com/apis and https://mydrupalsite.com/apis/uinque_id
> for these two page hits, even if 500 error occurred we don’t want to show
> the default HTML 500 error page which is configured at Nginx server level..
> But Nginx should present the same HTML 500 error page for all other page
> requests if 500 errors occurred while accessing those pages.
>
> Question is can we do any configuration changes at Nginx , so that it will
> not do anything even if 500 error occurred for that specific two types of
> page request mentioned above while it will still consider other page
> requests apart from these two for showing up the HTML error page as per the
> configuration if 500 error occurred.
>
> Problem that we are facing - We are handling the 500 error at code level
> in Drupal end and we are sending JSON data, but that is not getting
> displayed as Nginx taking the control of 500 error and it’s showing up the
> HTML error page. We already verified that when we are removing that Nginx
> 500 error page configuration, in that case we are getting JSON data that
> Drupal sent for 500 errors.
>
> So I think, if somehow we can pass the information to Nginx to not take
> any action if 500 error occurred while hitting the
> https://mydrupalsite.com/apis or https://mydrupalsite.com/apis/uinque_id
> URLs then our job will done, because in that case whatever Drupal is
> sending we will be able to see that if 500 error occurred. Please note that
> for the URLhttps://mydrupalsite.com/apis/uinque_id , uinque_id is a
> parameter and it can be changed.
>
> I have attached the nginx.conf file for your reference.
>
> Please guide me. Thanks in advance. I look forward to hearing from you.
>
> Best Regards,
>
> Kaushal
>

Hi,

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

Best Regards,

Kaushal
_______________________________________________
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: 313
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