Welcome! Log In Create A New Profile

Advanced

Re: Hide a request cookie in proxy_pass

November 29, 2017 11:49AM
Hello,

I've found strange behaviour with this rewrite method.
When :
- there are space (%20) in the URI
And
- a cookie match regexp (and is removed)

Nginx replace ";" and " " in Cookie header with %3B%20

For example:
I want to remove "Testy" cookie.
Here is nginx sample config :
server {
set $new_cookie $http_cookie;
if ($http_cookie ~ "(.*)(?:^|;)\s*Testy=[^;]+(.*)") {
set $new_cookie $1$2;
}
if ($new_cookie ~ "^[;]+(.*)") {
set $new_cookie $1;
}
proxy_set_header Cookie $new_cookie;
proxy_pass http://www.com_backend;
}
upstream www.com_backend {
server localhost:9020;
keepalive 30;
}


With this request :
GET /api/TEST%20TEST HTTP/1.1
Cookie: country_code=FR; session=IntcI; lastvisitfor=IjIwMT%3D; Testy=uid%08474524469%26fst%3D15118; teaser=eyJ0eXBl2; popin=eyJib3R0

Nginx remove correctly Testy cookie but forward this cookie header to backend:
Cookie: country_code=FR%3B%20session=IntcI%3B%20lastvisitfor=IjIwMT%3D%3B%20teaser=eyJ0eXBl2%3B%20popin=eyJib3R0

Due to the fact there are no "; " anymore, backend consider there is only one big cookie : "country_code".

nginx version: nginx/1.12.1
OS : CentOS 6.9

Any ideas on how to fix it ?
Thanks.

Anto
Subject Author Posted

Hide a request cookie in proxy_pass

gthb August 29, 2014 11:55AM

Re: Hide a request cookie in proxy_pass

Maxim Dounin August 29, 2014 01:28PM

Re: Hide a request cookie in proxy_pass

gthb September 02, 2014 06:16AM

Re: Hide a request cookie in proxy_pass

jwal November 14, 2016 06:14PM

Re: Hide a request cookie in proxy_pass

jwal November 14, 2016 06:16PM

Re: Hide a request cookie in proxy_pass

AntoUX November 29, 2017 11:49AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 81
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready