S
S
saxer2015-08-03 19:57:07
Nginx
saxer, 2015-08-03 19:57:07

Is it possible to configure nginx so that it saves server request cookies, and then restores them in the response from the backend?

Is it possible to configure nginx so that it saves the cookies I'm interested in, after which it erases all cookies and sends a request to the backend, having received a response from the backend, you need to restore the previously saved nginx cookies for this session before sending it to the user and only after that send the response to the user. Is it possible?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dan Ivanov, 2015-08-03
@ptchol

What, an option like

location ~* \.php$ {
...
  set $saved_cookie $cookie_omomomom;
  proxy_hide_header $cookie_badcracker;
  add_header $saved_cookie;
...
}

does not work ?
From the documentation
$cookie_ name
the name cookie

S
saxer, 2015-08-03
@saxer

I have a bunch of nginx-> varnish-> apache
varnish that provides caching, but it only caches requests that come from apache without cookies at all, otherwise it doesn’t cache them, so I need to save user session cookies in nginx (then ajax om I I’ll make friends with a basket of goods, etc.), after that we clear all cookies and pass it to varnish if it doesn’t have this page in the cache, then it redirects the request to apache apache gives the page (without cookies), varnish writes it to the cache and gives it to nginx, it in turn adds the user session cookies saved at the first stage to it, when another user accesses the same page again, varnish will no longer access apache, but will return a cached page to which nginx must add the cookies of the user who accesses it, such is the actual idea

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question