1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How can i have multiple nginx plus servers route to the same app servers with sticky sessions on?

Discussion in 'Nginx' started by mattmanforum, Jun 17, 2015.

  1. #1
    I have multiple nginx instances behind an AWS elastic load balancer. In the nginx config files, I am using ip_hash to force sticky sessions when connecting upstream. Is there a way to sync the route tables between the multiple nginx servers, so that no matter which nginx server handles the request, the traffic is sent to the same backend application server.

    When I first set this scenario up, I had no problems. But after heavy testing with multiple clients from different parts of the world, I was able to verify that the multiple nginx servers were not choosing the same backend application servers to route to. If I drop down to one nginx server, i can not recreate the issue.

    Attached is a diagram of my setup. elbnginxdrawingforsupportforums.png
     
    mattmanforum, Jun 17, 2015 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    You could pass it back as a response header to the client via AJAX, and trigger a callback to AJAX POST a 'preferred' app-server id somewhere, having the one initially used. This is of course at the code level, to do this at the NGINX level, you might consider nginx-sticky-module.
     
    zacharooni, Oct 5, 2015 IP