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。