Nginx wildcard regex server_name

When using nginx and as server_name i use anything else than straight string then kirby stops working.

The reason is kirby seems to use SERVER_NAME instead of HTTP_HOST i am not sure about reasoning around this but it means that when i want to use something like

server_name "~^(?<sub>.+)\.domain\.com$";
root /var/www/domains.domain.com/$sub;

Then

$_SERVER['HTTP_HOST'] = sub.domain.com
$_SERVER['SERVER_NAME'] = "~^(?<sub>.+)\.domain\.com$

I am using this just for development server so it is no really issue but it seems to me that some people might use regex in server names and redirect based on that? I mean i can imagine myself needing this.

But maybe i am missing something.

I thought it can be hack-fixed by doing

c::set('url', $_SERVER[REQUEST_SCHEME]. "://".$_SERVER[HTTP_HOST]);

But then parts of the panel stop working. Seems like there is some inconsistency.

Thank you