<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<div>Hello, everyone.</div>
<div><br /></div>
I’m writing a website with <b>Flask</b>. I use <b>Flask-Security</b> to do <span style="color: rgb(36, 39, 41); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">authentication and use N<b>ginx + Gunicorn</b> to deploy it.</span>
<div><span style="color: rgb(36, 39, 41); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><br /></span></div>
<div><span style="color: rgb(36, 39, 41); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">And I find a problem that <b>Flask-Security</b> can’t work with <b>Gunicorn</b> with multiple workers.</span></div>
<div><span style="color: rgb(36, 39, 41); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);"><br /></span></div>
<div><span style="color: rgb(36, 39, 41); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 15px; font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);">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></div>
<div>
<ol>
<li><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size: 15px;">It will login normally;</span></font></li>
<li><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size: 15px;">It will redirect to login page again;</span></font></li>
<li><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size: 15px;">It will redirect to the page protected by Flask-Security with unlogined status.</span></font></li>
</ol>
<div><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size: 15px;">After I expose Gunicorn server to public, It remains. </span></font></div>
</div>
</div>
</body>
</html>