skip to Main Content

I’m trying to implement sticky sessions in Nginx for a limited time based on a cookie generated by a Python application. In the nginx.conf file, I know I can use ip_hash to ensure that I stay on the same server. However, I need to remain on the same server for only 1 minute before being directed to a different server.

2

Answers


  1. Use the nginx sticky directive.

    For example:

    upstream backend {
        server backend1.example.com;
        server backend2.example.com;
    
        sticky cookie srv_id expires=1h domain=.example.com path=/;
    }
    
    Login or Signup to reply.
  2. do you know the answer? Because I also encountered the same problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search