switch off html wrapping of errors in nginx -


i use nginx on ubuntu forward requests spring boot-driven api server. api returns body 4xx , 5xx errors, client application consumes. e.g. in api code might return:

{   "message": "blah" } 

however nginx seems wrap errors html , embeds response within them. there way disable behavior? , there way en masse (i.e. 4xx , 5xx errors, without explicitly writing them out error_page example)

similar question , accepted answer here, seems bit of hack. i'm sure there's better way of doing this...

edit: config looks this:

server {     listen 80;      server_name my.domain.com;      location / {             proxy_pass http://127.0.0.1:9001;     } } 

you need add error_page directive inside location

server {     listen 80;      server_name my.domain.com;      location / {             error_page 404 = 404;             proxy_pass http://127.0.0.1:9001;     } } 

what cancel error_page previous directives set @ http block. , pass result client is. don't want codes json should sent client in error_page directive.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -