upstream resin {
#ip_hash;
server 10.10.69.206:8088;
server 10.10.69.206:8089 backup;
}
upstream edtold {
#ip_hash;
server 10.10.69.206:8089;
}
location ~ ^/pic/(.*)$ {
#proxy_set_header Host bjctc.azure.sohu.com;
#proxy_set_header Authorization IfI9RK0wiqEAsRKYBYLz/Q==:oRq3wTvlScelecBPOTYUnA==;
#proxy_pass http://10.10.89.33/peakviewcnc/$1;
more_set_headers "Content-type:image/jpeg";
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_pass http://resin;
proxy_intercept_errors on;
#recursive_error_pages on;
expires 7d;
}
error_page? 400 = @backup;
error_page? 405 = @backup;
location @backup{
#access_log off;
if ($request_method = POST) {
return 404;
}
proxy_pass http://edtold;
#rewrite?? "^/pic/(.*)$" /pic/$1 break;
expires 7d;
}
利用了upstream和? proxy_next_upstream 。当主的服务无相应或者当机就启用backup服务,当主机链接进入后出现错误如:http_500 http_502 http_503 http_504 error timeout invalid_header也用backup的,
当出现400和405错误也启用backup。
本文详细解读了使用upstream和proxy_next_upstream指令实现的HTTP代理与负载均衡策略,包括主服务与备份服务的切换机制,以及针对特定错误状态的故障转移策略。
984

被折叠的 条评论
为什么被折叠?



