﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
2631	version 1.25.5 virtual servers regexp variable is not available	zijiren233@…		"https://nginx.org/en/docs/stream/ngx_stream_core_module.html#server_name

I tried the function and config:
server {
    listen 443;
    server_name ~^(www\.)?(.+)$;
    # temporarily closed dns resolver, problems can be found in domain name resolution errors
    # resolver 1.1.1.1;

    proxy_pass www.$2:443;
}

or:
server {
    listen 443;
    server_name ~^(www\.)?(?<domain>.+)$;

    proxy_pass www.$domain:443;
}

However, it was found in the error that the variables matched by the regular expression are not available, such as $1 $2 $domain, they are all empty strings.
2024/04/24 15:11:20 [error] 20#20: *1 no resolver defined to resolve **www.**, client: 127.0.0.1, server: 0.0.0.0:443, bytes from/to client:0/0, bytes from/to upstream:0/0"	defect	closed	critical		nginx-core	1.25.x	wontfix	virtual servers server_name regexp	zijiren233@…	Linux ip-172-31-2-17 6.1.0-18-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 Linux	"nginx version: nginx/1.25.5
built by gcc 13.2.1 20231014 (Alpine 13.2.1_git20231014) 
built with OpenSSL 3.1.4 24 Oct 2023
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -g' --with-ld-opt='-Wl,--as-needed,-O1,--sort-common -Wl,-z,pack-relative-relocs'"
