D
D
demsi2016-07-13 18:14:20
linux
demsi, 2016-07-13 18:14:20

Nginx - how to send half of the users to a different URI?

There are two modifications of the web application
/var/www/new_app
/var/www/old_app
root is set to /var/www
Url All users go to - example.com/old_app/index.html. This url cannot be changed yet.
Requests come to nginx /old_app/index.html
I would like to make half of the requests go to / new_app /index.html
Make
rewrite ^/old_app/index.html$ /new_app/index.html;
Not a problem.
But how to do it, some condition so that this happens for half of the requests. But not for everyone.
UPDATE1:
Thanks for the tips.
Another limitation fell on the task. For some applications, requests are proxied from third-party resources.
Therefore, some applications receive requests from the same ip and UA.
Therefore, ngx_http_split_clients_module is not very suitable for us. It is not clear on what parameter to separate requests.
Therefore, I decided to take Lindon_cano 's advice :
" 1. Make two more hosts in nginx listening to different ports on 127.0. the other, if you want a third and two-thirds, whatever you like. "

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
ky0, 2016-07-13
@demsi

There is a special module for such things - ngx_http_split_clients_module .

Z
zelsky, 2016-07-13
@zelsky

Look at what sharding is for a database, and then I think the essence will be clear to you. If there is no exact definition of who to send to the new url.

V
Vmedmen, 2016-07-13
@qualitat

The first thing that came to mind was the distribution of users over time.
1, 3, 5, 7, 9 - odd numbers
2, 4, 6, 8 - even numbers, + 0.
I think conditions and regular expressions can be done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question