Created
March 3, 2017 20:52
-
-
Save foxumon/0ca92a837c6601277ebeecb227407e52 to your computer and use it in GitHub Desktop.
Nginx redirect load balancing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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