Answer the question
In order to leave comments, you need to log in
Nginx server - how to make a redirect from one domain to 2 different sites in it, 50\50?
Now the situation is something like this.
server {
listen 80;
server_name my-server-side.com;
return 301 http://my-another-site.ru;
}
The question is how to make it so that when visiting my-server-side.ru in 50% of cases the redirect occurs to http://my-another-site.ru, and in 50% to my-another-another-site.ru ?
Answer the question
In order to leave comments, you need to log in
nginx.org/ru/docs/http/ngx_http_split_clients_modu...
https://gist.github.com/jmervine/6077243
Official dock in Russian with examples The percentage of hits on each backend is set by the weights of the backends.
split_clients "${remote_addr}AAA" $redirectto {
50% domain2;
* domain1;
}
return 301 http://$redirectto ;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question