<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Hi 王帅,<br></div>
<div><br></div>
<div>It seems that somehow your application is storing information that's only available to the Gunicorn instance that the client connects to.<br></div>
<div><br></div>
<div>Have you tested forcing the same user connecting always to the same Gunicorn instance? That should probably work.<br></div>
<div><br></div>
<div>Where are you storing the session information?<br></div>
<div><br></div>
<div id="sig38188977"><div class="signature">-- unai<br></div>
</div>
<div><br></div>
<div><br></div>
<div>On Tue, Jan 10, 2017, at 02:11 PM, 王帅 wrote:<br></div>
<blockquote type="cite"><div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif;"><div>Hello, everyone.<br></div>
<div><br></div>
<div>I’m writing a website with<b>Flask</b>. I use <b>Flask-Security</b> to do <span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif"><span class="size" style="font-size:15px">authentication and use N<b>ginx + Gunicorn</b> to deploy it.</span></span></span></span> <br></div>
<div><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif"><span class="size" style="font-size:15px"></span></span></span></span><br></div>
<div><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif"><span class="size" style="font-size:15px">And I find a problem that <b>Flask-Security</b> can’t work with <b>Gunicorn</b> with multiple workers.</span></span></span></span><br></div>
<div><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif"><span class="size" style="font-size:15px"></span></span></span></span><br></div>
<div><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif"><span class="size" style="font-size:15px">If the worker number is <b>one</b>, I can login normally. If the worker number of Gunicorn is <b>greater than one</b> or there is <b>more than one</b> <b>Gunicorn</b> servers behind <b>Nginx</b>, There are three situations will happen:</span></span></span></span><br></div>
<div><ol><li><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial," Helvetica Neue"," Helvetica"," sans-serif""><span class="size" style="font-size:15px">It will login normally;</span></span></span><br></li><li><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial," Helvetica Neue"," Helvetica"," sans-serif""><span class="size" style="font-size:15px">It will redirect to login page again;</span></span></span><br></li><li><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial," Helvetica Neue"," Helvetica"," sans-serif""><span class="size" style="font-size:15px">It will redirect to the page protected by Flask-Security with unlogined status.</span></span></span><br></li></ol><div><span class="colour" style="color:rgb(36, 39, 41)"><span class="font" style="font-family:Arial," Helvetica Neue"," Helvetica"," sans-serif""><span class="size" style="font-size:15px">After I expose Gunicorn server to public, It remains. </span></span></span><br></div>
</div>
</div>
<div><u>_______________________________________________</u><br></div>
<div>Flask mailing list<br></div>
<div><a href="mailto:Flask@python.org">Flask@python.org</a><br></div>
<div><a href="https://mail.python.org/mailman/listinfo/flask">https://mail.python.org/mailman/listinfo/flask</a><br></div>
</blockquote><div><br></div>
</body>
</html>