two web2py servers and sessions in redis

49 views
Skip to first unread message

Yoel Benitez Fonseca

unread,
May 7, 2020, 3:48:21 PM5/7/20
to web2py-users
Got the following situation:

- Two applications released as lambda functions (A and B), each application in this scenary have his own web2py version, served with the same domain name behind an nginx proxy, for example A (example.com) and B (example.com/path_to_b).
- i wanted that B uses A as a CAS provider.
- both using the same REDIS server for sessions (the exact same settings in both applications/web2py instances):

from gluon.contrib.redis_utils import RConn
from gluon.contrib.redis_cache import RedisCache
from gluon.contrib.redis_session import RedisSession

redis_conection = RConn(
    host=configuration.get('redis.host'),
    port=configuration.get('redis.port'))

session.connect(request, response, db=RedisSession(redis_conection))

B keeps redirecting me to the A login page, after some heavy debugging I realized that the problem could be the sessions and tested using sessions in database for B and well it worked fine.

So the question is: two, separate, web2py instances can't share the same redis server ? i mean, in my case is not a lambda function with 2 applications, each application in this scenary have his own web2py version - for reasons outside this discussion - and i wished to reuse the already deployed redis server. Is there some kind of conflict betwen each web2py instance?

Annet

unread,
May 8, 2020, 4:51:37 AM5/8/20
to web2py-users
I had a similar problem, Anthony explained to me that I should
share the session cookie among all subdomains under the
main domain:

response.cookies['session_id_A']['domain'] = '.example.com'


I hope this points you in the right direction to solve the issue.


Annet
Reply all
Reply to author
Forward
0 new messages