below is my Nginx conf, I want to redirect my URL to another page if /api throws the error code is 502, How can I do it in nginx.
location ~*/api {
rewrite ^/api(.*) $1 break;
proxy_pass http://127.0.0.1:3200;
client_max_body_size 60M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location ~*/api/test {
rewrite ^/api/test/(.*) /test/$1 break;
proxy_pass http://127.0.0.1:3200;
client_max_body_size 60M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
I have 2 locations 1) location ~/api 2/ location ~/api/test if the location ~/api gets 502 error i need to redirect to location ~/api/test