I need to set different values of custom response header based on response from the proxy_pass backend response code.
I tried many different ways, but still can't figure out how this can be done.
location /mypath {
#for 200,301,302,etc "good" responses from 127.0.0.1:8080 I need to set value 60
add_header X-MyCustomHeader 60;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
#for 404,403 responses from 127.0.0.1:8080 I need to set X-MyCustomHeader=5
#for 500 responses from 127.0.0.1:8080 I need to set X-MyCustomHeader=1
}
Any help is appreciated.