Acho que podemos processar isso com openresty
aqui é exemplo
arquivo conf nginxserver {
listen 8081;
server_name localhost;
location / {
content_by_lua_block {
ngx.say('8081 version')
}
}
}
server {
listen 8082;
server_name localhost;
location / {
content_by_lua_block {
ngx.say('8082 version')
}
}
}
server {
listen 80;
server_name localhost;
location / {
set $versionupstream "";
rewrite_by_lua_block {
local newcookie = ngx.var.cookie_Foo
if newcookie == "bar" then
ngx.var.versionupstream = "127.0.0.1:8081"
else
ngx.var.versionupstream = "127.0.0.1:8082"
end
}
proxy_pass http://$versionupstream;
}
}
teste-o