Nginx load balancing to keep sessions between IIS servers
Francis Daly
francis at daoine.org
Fri Mar 27 08:30:41 UTC 2020
On Tue, Mar 24, 2020 at 06:01:35PM -0400, robe007 wrote:
Hi there,
> I have set up a load balancer with NGINX for two IIS web servers that works
> with sessions.
What is "a session"?
The answer to that may make it clear how to achieve what you want.
> upstream mybalancer {
> ip_hash;
> server server1.com:80;
> server server2.com:80;
> }
>
> #Server
> server {
> server_name server3.com;
> location / {
> proxy_pass http://mybalancer;
> }
> }
>
> When I make a request to server3.com it gets redirected -for example- to
> server1.com. Next I make the login, go to a specific page, let's say:
> server1.com/welcome/maps. Everything is ok.
That... probably should not happen.
In a reverse proxy situation, your client should not know (or care)
whether it is talking to server1 or to server2 -- it only interacts
with server3.
(It is possible that I am just misunderstanding the terminology here.)
> Now I turn off server1.com, and NGINX redirects me to server2.com, but
> prompts me to the login page.
I think "no".
server2 asks you to login; nginx does not. And that difference matters
here.
> It's possible to configure NGINX to keep the same sessions when one server
> goes down? This means that -in my example- NGINX could redirect me to
> server2.com/welcome/maps with the same session.
Back to the first question -- what is a session?
I suspect that in your system it is "state stored on the back-end server1
or server2"; and it is not anything that the browser knows about and
not anything that nginx knows about. The browser might have a "key"
to the session in a cookie.
If that is the case, then the fix would be for you to make sure that
server1 and server2 both have the same shared idea of a session, so that
the same cookie sent to either server will end up with the same response.
And there is nothing the nginx can do about arranging that.
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list