Tuesday, 3 December 2019

maintaining sessions across multiple node-red instances hosted on same domain

I have multiple node-red application running on different servers using a single domain name through Nginx like:

server {
  server_name abc.com www.abc.com; #main website
  root /var/www/web;
  index index.html;

location /server/demo{
    proxy_pass http://xx.xxx.xx.xx:1880/server/demo; #node-red app 1
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

location /server/demo2{
    proxy_pass http://yy:yyy:yy:yy:1880/server/demo2; #node-red app 2
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

location /server/demo3{.....  #node red app 3
......
......

I'm not sure but I think the same session or cookie is shared by all these instances so I'm not able to log in to multiple instances of my application in the same browser/machine(even though they are running on different servers). If I login to one node-red instance and then in a new tab if I log in to another I get logged out of the first one.

For example, I'm not able to login to abc.com/server/demo1 and abc.com/server/demo2 simultaneously but I am able to login to multiple instances using their IP addresses http://xx.xxx.xx.xx:1880/server/demo and http://yy:yyy:yy:yy:1880/server/demo2.

Is there a way to set up HTTP cookie for each location object in Nginx if that itself is the issue here? or A better approach to achieve this functionality?



from maintaining sessions across multiple node-red instances hosted on same domain

No comments:

Post a Comment