I know how to set variables and use subroutines with the nginx builtin perl module INSIDE a "server" directive but, what I need to do is to set/rewrite the current domain before.
Let's say, we have a domain like
admin.foobar.website.com
I want that a request to
foobar.othersite.com
to point to the first address ( obviously website.com and othersite.com are hosted on the same webserver running nginx :) ).
For reasons I can't explain here, I can not use multiple server_name directive expressions, I have to do this before the server {} block, with perl or anyway possible.