K
K
ksenofor2014-07-15 15:34:15
Nginx
ksenofor, 2014-07-15 15:34:15

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

3 answer(s)
S
Sergey, 2014-07-15
Protko @Fesor

nginx.org/ru/docs/http/ngx_http_split_clients_modu...
https://gist.github.com/jmervine/6077243

S
Sergey Petrikov, 2014-07-15
@RicoX

Official dock in Russian with examples The percentage of hits on each backend is set by the weights of the backends.

V
Vlad Zhivotnev, 2014-07-18
@inkvizitor68sl

split_clients "${remote_addr}AAA" $redirectto {
               50%               domain2;
               *               domain1;
}

return 301 http://$redirectto ;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question