Infrastructure:cloud:aws beanstalkturn on nginx for container proxy serverapplication load balancer - https only, default process (https)2+ instance in private subnetenabled end to end encryption followinghttps://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-endtoend.htmlhttps://docs.aws.amazon.com/elasticbeanstalk/latest/dg/https-singleinstance-docker.htmlself-signed certificate on instanceinstance running dockerIn local, we have a 3 container to mimic the infrastructure,1 nginx: 443 as load balancer and https reverse proxy2 app container: 3000:3000, 3001:3001 respectivelyso, not end to end encryption yetsoftware:authopassport(https://github.com/auth0/passport-auth0)expressreactcookie-session packageconst sessionConfig = {name: 'sessionId',secret: uid.sync(18),secure: true,httpOnly: true,secureProxy: true,maxAge: 1800 * 1000};workflow:open website, click login link, it then redirect us to auth0 login page, after input username/passport, we click submit.We are encountering "redirect too many times" when we have more than 1 instance running. The issue goes away if I turn on sticky session on the target group in aws.We are seeing the same when trying on the local docker environment.In this code,```router.get('/callback', (req, res, next) => {authenticate('auth0', (authErr, user) => {if (authErr) {console.error(`Error authenticating user: ${authErr}`);return next(authErr);}if (!user) {console.info(`No user data, redirecting to login page`);return res.redirect('/login');}```The logic always hits - if (!user), and we are not sure why this happens with multiple instance, load balancer setup.Please advise and help.Jay
Submitted July 29, 2019 at 11:40PM by ufsi7259
No comments:
Post a Comment