Score:0

flask session work in a development server, but not in a production server(nginx)

am flag

I have created a webapp with an authentication system. I use the session module to check if a user is logged in. During the login phase, I set session['logged_id'] = True, and when a client tries to access the homepage, I check if session['logged_in'] is equal to True. But after creating an account, when I try to access the homepage, through the login page, I am redirected to the login page again, even though the password is correct. So, I think session['logged in'] still false

The WebApp works fine in development server, but does't work in a production server, in this case nginx and gunicorn as wsgi server.

So I don't think it's a code related issue, but related to the nginx or gunicorn configuration

This is my nginx configuration file

server {
    listen 80;
    server_name 192.168.1.15;
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/pi/website/ris2023/ris.sock;
    }
}

This is my gunicorn service file

[Unit]
Description=istanza di gunicorn per eseguire l'applicazione flask
After = network.target

[Service]
User = pi
Group = www-data
WorkingDirectory = /home/pi/website/ris2023
Environment = "PATH=/home/pi/website/ris2023/venv/bin"
ExecStart=/home/pi/website/ris2023/venv/bin/gunicorn --workers 3 --bind unix:ris.sock -m 007 wsgi:app

[Install]
WantedBy=multi-user.target

I have tried with flask-login too, but i have the same issue

pt flag
I think it would be useful if your question included a minimal Flask app that reproduces this behavior.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.