<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="Helvetica, Arial, sans-serif">The "internal" keyword
      indicates only internal request can access the location:<br>
      <br>
      <a moz-do-not-send="true"
        href="http://nginx.org/en/docs/http/ngx_http_core_module.html#internal"
        class="moz-txt-link-freetext">http://nginx.org/en/docs/http/ngx_http_core_module.html#internal</a><br>
      <br>
      So hitting ttp://mydomain.com/api/v1/*  with CURL would never hit
      this location.<br>
      <br>
      Remove the "internal" keyword, reload Nginx and try it again.<br>
      <br>
      -Dan<br>
    </font><br>
    <div class="moz-cite-prefix">On 11/7/2022 10:29 AM, Kaushal Shriyan
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAD7Ssm8SU9X6dPi38kAs1AxF_oehFv1Zp9B6q0U9LpqmZu44bQ@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi,<br>
        <div><br>
        </div>
        <div>I am running the <span class="gmail-il">nginx</span> version: <span
            class="gmail-il">nginx</span>/1.22 as a reverse proxy server
          on CentOS Linux release 7.9.2009 (Core). Is there a way to
          return json response when i hit <a
href="https://url.emailprotection.link/?bwxIfDuJKR1YH1mqneKAbav55uYd8-63cvdvlSLvw0mVdAEtaFGRd2iiGoI8nWnhImkBUGplq84IGc2dX0eDK2g~~"
            moz-do-not-send="true">http://mydomain.com/api/v1/*</a>
          instead of the html response.</div>
        <div><br>
        </div>
        <div>location /api/v1/* {<br>
              internal;<br>
              add_header 'Content-Type' 'application/json
          charset=UTF-8';<br>
          <br>
              error_page 502 '{"error": {"status_code": 502,"status":
          "Bad Gateway"}}';<br>
          }<br>
          <br>
          But whenever I try to send a request to /api/v1/users via curl
          I get the HTML source code in response instead of JSON
          response. <br>
        </div>
        <div><br>
        </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><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
nginx mailing list -- <a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
To unsubscribe send an email to <a class="moz-txt-link-abbreviated" href="mailto:nginx-leave@nginx.org">nginx-leave@nginx.org</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Dan G. Switzer, II
Giva, Inc.
Email:    <a class="moz-txt-link-abbreviated" href="mailto:dan.switzer@givainc.com">dan.switzer@givainc.com</a>
Web Site: <a class="moz-txt-link-freetext" href="http://www.givainc.com">http://www.givainc.com</a>

See Our Customer Successes 
<a class="moz-txt-link-freetext" href="http://www.givainc.com/customers-casestudies.htm">http://www.givainc.com/customers-casestudies.htm</a>
</pre>
  </body>
</html>