Score:1

Nginx - Session persistency over two chained Nginx Instances

in flag

I have a very special use case - and I'm wondering if there isn't a better solution.

Use case: Several users should be able to reach one of about 1000 target instances (C1 to C1000) coming from an Nginx instance (A) at the same time. Unfortunately, 100 target instances each have to be located behind a separate Nginx instance (B1 to B10) as a reverse proxy.

Problem: If several users jump in parallel from their respective client to A and from there then to one of the B Nginx instances and from there then to one of the underlying C target instances, the question arises of how to ensure the session consistency of each individual session. In addition, C target instances must be able to set session cookies on the respective client that comes to this C target instance via the A-Nginx instance, from there the respective B-Nginx instance.

My solution: Each user who calls A gets a separate port. The connections between A and the individual B instances run via separate ports, e.g. from A to B1 10000, A to B2 11000, etc., A to B10 20000. The connections from B instances to the C target instances are maintained on dedicated ports as well, e.g. connection B1 to C0001 on port 10001, connection B1 to C0002 on port 10002, etc..

I hate this construct, but it works. The question is - what am I missing. I can't imagine there isn't a more elegant way.

Does anybody has a good idea how to solve the problem with in a more elegant way? Maybe somehow with session cookies?

KInd regards, D.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.