The Lua code you gave works and does what I need here.
Still would be great to have an option like ...
... in the main proxy module though.
Anyway, solved at least.
Posted at Nginx Forum:http://forum.nginx.org/read.php?2,161969,168015#msg-168015
nginx mailing list