How to change/add cookie in http request for sticky?

Hasta-La-Vista_NN nginx-forum at forum.nginx.org
Mon Sep 4 19:10:01 UTC 2017


Hi all. So my situation is following:

I'm making some backend on java and using nginx as balancer (sticky module).
Sticky uses cookie for identify current server which browser is working
with. Browser sends such request as POST, OPTION, GET and so on. And all
these request contain cookie with route parameter. Firstly route parameter
is generated by sticky nginx and then browser use it fo following reqest.

My problem now is that frontend developers created DELETE request without
cookie. But they can write route parameter as parameter of request.
Something like that:

DELETE http://myserver.com/winter/user/john?route=12345
So this request can send on wrong upstream, because it hasn't cookie. My
solution is to add parameter located in url to cookie in nginx. But i don't
know why how to do it. My nginx:

upstream backend {
    server backend1.example.com;
    server backend2.example.com;

    sticky secure httponly;
}

server {
    ...

    location / {
        proxy_pass http://backend;
        ...
    }
}
proxy_set_header Cookie "route=$arg_route"; help me, doesn't it? Or is there
another way?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,276252,276252#msg-276252



More information about the nginx mailing list