Load balance using redirects
August 25, 2013 04:40AM
I have some edge HTTP based streaming servers that I need to load balance the traffic of, without that traffic having to proxy through the load balancer. I have used nginx as a proxy before with health checks on the back end servers in upstream and using proxy_pass, but in this instance I want to do this based on redirects, so that the load balancer itself does not take all the traffic, but simply responds with one of the edge servers to redirect too.

e.g.

http://mystream.example.com/streamname 301 redirect to:

http://edge1.mystream.example.com/streamname
http://edge2.mystream.example.com/streamname
http://edge3.mystream.example.com/streamname


I have seen similar examples as below:

http {
split_clients "${remote_addr}" $server_id {
33.3% 1;
33.3% 2;
33.4% 3;
}

server {
location ~* \.(gif|jpg|jpeg)$ {
return 301 "${scheme}://s${server_id}.site.com${request_uri}";
}
}


However the above lacks any health checks. What I need is a combination of above with back end health checks as offered in the upstream module, such that should edge1 be offline, it will not be redirected to.

Is this possible?


Thanks,

A
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 215
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready