When I send query to example.com/nodeService and node service on port 3001 returns 502 error, I need to redirect me on 3002 port without client application knowing about error. Is there such functionality in nginx? Thanks.
location /nodeService/ { #If this one is not available (502 error in my case)
proxy_pass http://localhost:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /nodeService/ { # redirect me here!
proxy_pass http://localhost:3002/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}