I'm currently trying to get nginx to add a header to the response when it is sending some kind of 50* error. I already have an add_header directive on the http block, and that gets respected for all requests except it seems errors. I also tried the following in one of my vhosts:
location /mediocregopheristhecoolest {
add_header X-Test "blahblahblah";
return 502;
}
Going to that page gives me a 502, but no header. Is this simply something nginx doesn't do, or am I doing it wrong?