当我向example.com/nodeService发送查询并且端口3001上的节点服务返回502错误时,我需要在3002端口上重定向我,而客户端应用程序不知道错误。 Nginx中有这种功能吗?谢谢。
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;
}