Welcome! Log In Create A New Profile


Nginx load balancing to keep sessions between IIS servers

March 24, 2020 06:01PM
I have set up a load balancer with NGINX for two IIS web servers that works with sessions. Here is the NGINX configuration file I have created for the load balancing:

#Log Format
log_format upstreamlog '$server_name to: $upstream_addr [$request] '
'upstream_response_time $upstream_response_time '
'msec $msec request_time $request_time';

upstream mybalancer {
server server1.com:80;
server server2.com:80;

server {
listen 80;
listen [::]:80;
server_name server3.com;

access_log /var/log/nginx/access.log upstreamlog;

location / {
proxy_pass http://mybalancer;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

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.

Now I turn off server1.com, and NGINX redirects me to server2.com, but prompts me to the login page.

My question:

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.


I have read on other posts about setting this options:

proxy_cookie_path ~*^/.* /;
add_header "Set-Cookie" "lb=$upstream_http_X_Loadbalance_ID";

but does not works.
Subject Author Posted

Nginx load balancing to keep sessions between IIS servers

robe007 March 24, 2020 06:01PM

Re: Nginx load balancing to keep sessions between IIS servers

Francis Daly March 27, 2020 04:34AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 115
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready