server {
listen 80;
server_name ~^(?<name>.+?)\.domain\.ru$;
root /var/www/$name;
....
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
...
}