How to configure nginx for proxying scheme user-id=resource?

The task of the next:
There are several servers, each of which enshrined their users. You want to make all users a single entry point (single host). Use the url as{user-id}/resource. Depending on user-id the request should be routed to a specific backend server. The list of users and their respective servers stored in the database.
I want to use nginx for routing, but do not know how to configure. After all, if a register location / proxy_pass for each user individually, it will be sooooo great config! Is there another way?
July 9th 19 at 12:49
1 answer
July 9th 19 at 12:51
Can use map to determine and find out.
I cookie to determine which server to send queries:
upstream backend {

map $cookie_server $upstream {
 default backend;
about map read, thanks! Yet, frankly, Your example do not understand. - kevon21 commented on July 9th 19 at 12:54
: if a visitor came with the cookie server=2 it sends to the backend address - Giles_Funk63 commented on July 9th 19 at 12:57

Find more questions by tags Nginx