Skip to content

Instantly share code, notes, and snippets.

@foxumon
Created March 3, 2017 20:52
Show Gist options
  • Save foxumon/0ca92a837c6601277ebeecb227407e52 to your computer and use it in GitHub Desktop.
Save foxumon/0ca92a837c6601277ebeecb227407e52 to your computer and use it in GitHub Desktop.
Nginx redirect load balancing
http {
split_clients "${remote_addr}" $mirror {
33% "http://google.com";
33% "http://yahoo.com";
* "http://bing.com";
}
server {
listen 0.0.0.0:80;
listen [::]:80;
server_name sub.domain.com www.sub.domain.com;
location / {
add_header X-Cache "Redirect load balancing";
if ($http_referer = "") {
set $mirror "http://duckduckgo.com";
}
return 302 $mirror;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment