Isso é possível usando Lua:
nginx.conf:
location /foo {
internal;
#Do normal stuff that you will do in this location
}
location /bar {
content_by_lua_block {
response = ngx.location.capture("/foo")
for cookieName, cookie in pairs(response.header["Set-Cookie"]) do
#Modify cookie as needed
end
}
}