Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vmanyushin/09ec77f4e070f40ff3de645ab8406f52 to your computer and use it in GitHub Desktop.
Save vmanyushin/09ec77f4e070f40ff3de645ab8406f52 to your computer and use it in GitHub Desktop.
split_clients "${remote_addr}${http_user_agent}${date_gmt}" $variant {
25% dg1;
25% dg2;
25% dg3;
25% dg4;
}
server {
listen 80;
listen 443 ssl;
server_name domain.lan;
if ($variant = dg1) {
set $redirect_url https://domain1.lan/url1;
}
if ($variant = dg2) {
set $redirect_url https://domain2.lan/url1;
}
if ($variant = dg3) {
set $redirect_url https://domain1.lan/url2;
}
if ($variant = dg4) {
set $redirect_url https://domain2.lan/url2;
}
location / {
return 302 $redirect_url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment