Nginx or Lighttd redirect to cdn when load is high

Im trying to set up a server for static asset delivery with NGINX, but I need to somehow check the load on the server to redirect all requests to a CDN if server is load is +x amount

for example

if(server_load > 50/100)
{
redirect all requests to cdn.stackpath.com
}
else {
serve_file();
}

Does nginx have anything like this? I could work with lighttpd too
Mario BernheimCTOAsked:
Who is Participating?
 
Aaron TomoskySD-WAN SimplifiedCommented:
You can set it up as a load balancer, perhaps with weights that you can adjust as the load changes?
http://nginx.org/en/docs/http/load_balancing.html

If it’s just static http images this should be fine, for anything https make sure you sticky sessions (iphash I believe for nginx)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.