<div dir="ltr"><div dir="ltr"> <br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 11, 2022 at 2:38 PM Francis Daly <<a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Nov 09, 2022 at 11:45:20PM +0530, Kaushal Shriyan wrote:<br>
<br>
Hi there,<br>
<br>
> Checking in again if someone can help me with my earlier post to this<br>
> mailing list?<br>
<br>
The question in the post was, and is, a bit unclear to me.<br>
<br>
You seem to be showing multiple different requests, so I'm not sure<br>
exactly what you are asking.<br>
<br>
Maybe it is also unclear to others? In that case,it may be useful if<br>
you can simplify your example question?<br>
<br>
> I have a follow up question, when the user invokes -><br>
> <a href="http://mydomain.com/apis" rel="noreferrer" target="_blank">http://mydomain.com/apis</a> <<a href="http://mydomain.com/api/v1/*" rel="noreferrer" target="_blank">http://mydomain.com/api/v1/*</a>>  -> Nginx Webserver<br>
> -> Drupal 9 Core CMS -> PHP-FPM backend server.<br>
> <br>
> Nginx should present the below info on 500 ISE error conditions for /apis<br>
> and /apis/* The below message sends back the response to Nginx web server<br>
> to render it to the client browser instead of the /error-500.html file<br>
> contents.<br>
> <br>
>                   "type" => "/problems/API-saving-error",<br>
>                   "title" => $this->t("Issue occured while saving the<br>
> API."),<br>
>                   "detail" => $this->t("There are some wrong inputs passed<br>
> to DB which caused this issue."),<br>
<br>
What one specific request do you want to make? (Maybe<br>
<a href="http://mydomain.com/apis" rel="noreferrer" target="_blank">http://mydomain.com/apis</a>, maybe <a href="http://mydomain.com/api/v1/*" rel="noreferrer" target="_blank">http://mydomain.com/api/v1/*</a>, maybe<br>
<a href="http://mydomain.com/api/v1/example" rel="noreferrer" target="_blank">http://mydomain.com/api/v1/example</a>, maybe something else?)<br>
<br>
For that one specific request, what do you want nginx to do with<br>
it? (Maybe make a http request to the Drupal system? Or a fastcgi request<br>
to the Drupal system? Or handle it internally withint nginx?)<br>
<br>
For the response from that request, what do you want nginx to do with<br>
it? (Send it to the user as-is? Mangle / modify it somehow? If so --<br>
how? Change the http response code or headers? Change the response body?)<br>
<br>
<br>
I suspect that if you can describe what exactly you want nginx to do,<br>
someone will have a better chance of sharing how to configure nginx to<br>
do that thing.<br>
<br>
> I have the below settings in nginx conf file<br>
> <br>
>              error_page 500 /error-500.html;<br>
>              location = /error-500.html {<br>
>              root<br>
> /var/www/html/gsmamarketplace/web/servererrorpages/error-pages-500-503/html;<br>
>              }<br>
<br>
For example: the above stanza says "if nginx is going to<br>
send a http 500 response, it should send the contents of the file<br>
/var/www/html/gsmamarketplace/web/servererrorpages/error-pages-500-503/html/error-500.html<br>
as the response body", along with the http 500 response header.<br>
<br>
If that is what you want nginx to do, the configuration is correct. If<br>
it is not, it is not.<br>
<br>
> I am trying to set the below location and try_files directive block in<br>
> nginx.conf file<br>
>      location /apis {<br>
>             try_files $uri $uri/ /path/to/api/handler; (This part is not<br>
> clear with me)<br>
>             }<br>
<br>
And I can see what this nginx config will do; but I do not know what you<br>
want it to do. If you can give the full details for one example request,<br>
then maybe it will become clear to me. (And maybe others will be able<br>
to help too, if they are similarly confused.)<br>
<br>
Thanks,<br>
<br>
        f<br>
-- <br>
Francis Daly        <a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a><br>
_______________________________________________<br>
nginx mailing list -- <a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
To unsubscribe send an email to <a href="mailto:nginx-leave@nginx.org" target="_blank">nginx-leave@nginx.org</a></blockquote></div></blockquote><div><br></div><div> Hi,</div><div><br></div><div>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.<br><br>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 <a href="https://mydrupalsite.com/apis">https://mydrupalsite.com/apis</a> and <a href="https://mydrupalsite.com/apis/uinque_id">https://mydrupalsite.com/apis/uinque_id</a> 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.<br><br>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.<br><br>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.<br><br>So I think, if somehow we can pass the information to Nginx to not take any action if 500 error occurred while hitting the  <a href="https://mydrupalsite.com/apis">https://mydrupalsite.com/apis</a> or  <a href="https://mydrupalsite.com/apis/uinque_id">https://mydrupalsite.com/apis/uinque_id</a>  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://<a href="http://mydrupalsite.com/apis/uinque_id">mydrupalsite.com/apis/uinque_id</a>  , uinque_id is a parameter and it can be changed.  <br></div><div><br></div><div>I have attached the nginx.conf file for your reference. </div><div><br></div><div><div>Please guide me. Thanks in advance. I look forward to hearing from you. </div><div><br></div><div>Best Regards,</div><div><br></div><div>Kaushal</div></div></div></div>