nginx returns html instead of json response

Kaushal Shriyan kaushalshriyan at
Mon Nov 7 15:29:51 UTC 2022


I am running the nginx version: nginx/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* instead of the html

location /api/v1/* {
    add_header 'Content-Type' 'application/json charset=UTF-8';

    error_page 502 '{"error": {"status_code": 502,"status": "Bad

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.

Please guide me. Thanks in advance. I look forward to hearing from you.

Best Regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list