nginx returns html instead of json response

Kaushal Shriyan kaushalshriyan at gmail.com
Fri Nov 11 10:51:20 UTC 2022


Thanks Francis for the email and appreciate it. I will explain in detail
about this specific usecase. Thanks once again.

On Fri, Nov 11, 2022 at 2:38 PM Francis Daly <francis at 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 at daoine.org
> _______________________________________________
> nginx mailing list -- nginx at nginx.org
> To unsubscribe send an email to nginx-leave at nginx.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20221111/c54700ac/attachment.htm>


More information about the nginx mailing list