On Tue, Nov 8, 2022 at 11:20 AM Maxim Dounin wrote:
> Hello!
>
> On Mon, Nov 07, 2022 at 08:59:51PM +0530, Kaushal Shriyan wrote:
>
> > 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
Hello!
On Mon, Nov 07, 2022 at 08:59:51PM +0530, Kaushal Shriyan wrote:
> 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 http://mydomain.com/api/v1/* instead of the html
> response
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
On Mon, Nov 7, 2022 at 9:40 PM Dan G. Switzer, II
wrote:
> The "internal" keyword indicates only internal request can access the
> location:
>
> http://nginx.org/en/docs/http/ngx_http_core_module.html#internal
>
> So hitting ttp://mydomain.com/api/v1/* with CURL would never hit this
> location.
The "internal" keyword indicates only internal request can access the
location:
http://nginx.org/en/docs/http/ngx_http_core_module.html#internal
So hitting ttp://mydomain.com/api/v1/* with CURL would never hit this
location.
Remove the "internal" keyword, reload Nginx and try it again.
-Da
Hi,
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 http://mydomain.com/api/v1/* instead of the html
response.
location /api/v1/* {
internal;
add_header 'Content-Type' 'applicat