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
Dan G. Switzer, II
November 07, 2022 01:22PM
Error page doesn't allow a string content as return (at least it's not
documented as being valid).

Try:

location /apis/* {
    add_header 'Content-Type' 'application/json charset=UTF-8';
    return 500 '{"error": {"status_code": 500,"status": "Internal
Server error"}}';
}

-Dan

On 11/7/2022 12:47 PM, Kaushal Shriyan wrote:
>
>
> On Mon, Nov 7, 2022 at 9:40 PM Dan G. Switzer, II
> <dan.switzer@givainc.com> wrote:
>
> The "internal" keyword indicates only internal request can access
> the location:
>
> http://nginx.org/en/docs/http/ngx_http_core_module.html#internal
> https://url.emailprotection.link/?bKzOBHGoVTgMZbVl06OjtjX6aHusF64x7ioKV57xsa8lK5HrhUog6H03w4i49Ibf0uYwbM9e74mZ2RElJBcCfPJ4yQW6AkMPmgxM2SKhEDl3WxQF7mffOIcAwcvVg3N1I
>
> So hitting ttp://mydomain.com/api/v1/*
> https://url.emailprotection.link/?bwxIfDuJKR1YH1mqneKAbav55uYd8-63cvdvlSLvw0mVdAEtaFGRd2iiGoI8nWnhImkBUGplq84IGc2dX0eDK2g~~
> with CURL would never hit this location.
>
> Remove the "internal" keyword, reload Nginx and try it again.
>
> -Dan
>
>
> Thanks Dan for the email response.I am still seeing the below response
> in html format. I am attaching the nginxtest.conf file for your
> reference.
>
> _/var/log/nginx/access.log
> _
> 48.219.29.210 - - [07/Nov/2022:17:33:38 +0000] "POST /apis HTTP/1.1"
> 500 1678279 "-" "PostmanRuntime/7.29.2" "-"
>
> _Response in html format_
> _
> _
> ############################################################################################################
> <!doctype html>
> <html lang="en">
>
> <head>
> <title>500</title>
> <meta charset="utf-8">
> <meta name="description" content="500">
> <link rel="preconnect" href="https://fonts.gstatic.com
> https://url.emailprotection.link/?by-dLw9LwJmO5vEZpHedagRmqu5Hzr5-4SwcSmbg7a4wCJN60WQwnE73R4jiVqy2JURqdMNsclU-C1XzywjIrkQ~~">
> <meta name="viewport" content="width=device-width, initial-scale=1.0">
> <link rel="icon" href="favicon.ico" type="image/gif" sizes="32x32">
> <style>
> @font-face {
> font-family: "UniversNextHSBC-Light";
> src:
> url("/themes/custom/gsmamarketplace/font/UniversNextforHSBCW29-Light.woff2")
> format("woff2");
> }
>
>
> </div>
>             <div class="error-content">
>                 <h1>500 <br> Internal server problem</h1>
>                     <p>Sorry, An error occurred and your request
> couldn't be completed. <a href="/">Return to the home
>                             page</a></p>
>             </div>
>         </div>
>     </div>
> </body>
> </html>
>
> ############################################################################################################
>
> Please guide me. Thanks in advance. I look forward to hearing from you.
>
> Best Regards,
>
> Kaushal
>
> _______________________________________________
> nginx mailing list --nginx@nginx.org
> To unsubscribe send an email tonginx-leave@nginx.org

--
Dan G. Switzer, II
Giva, Inc.
Email:dan.switzer@givainc.com
Web Site:http://www.givainc.com

See Our Customer Successes
http://www.givainc.com/customers-casestudies.htm
_______________________________________________
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: 273
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