Opened 3 years ago

Closed 3 years ago

#1256 closed defect (invalid)

match-all regex server name not always matching

Reported by: namazso@… Owned by:
Priority: major Milestone:
Component: other Version: 1.10.x
Keywords: domain regex Cc:
uname -a: Linux nymph 4.9.0-2-amd64 #1 SMP Debian 4.9.13-1 (2017-02-27) x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.3
built with OpenSSL 1.1.0d 26 Jan 2017 (running with OpenSSL 1.1.0e 16 Feb 2017)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-F3HeH5/nginx-1.10.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_gzip_static_module --without-http_browser_module --without-http_geo_module --without-http_limit_req_module --without-http_limit_conn_module --without-http_memcached_module --without-http_referer_module --without-http_split_clients_module --without-http_userid_module --add-dynamic-module=/build/nginx-F3HeH5/nginx-1.10.3/debian/modules/nginx-echo

Description

I have a server, with the name

~^(?<domain>.+)$

that is supposed to catch any domain, however it works for some domains, and doesn't work for some others.

Here is an example of once working and once not:

2017/04/22 21:30:25 [error] 3941#3941: *3 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.68.226.80, server: test.namazso.eu, request: "GET /nonexistent.php HTTP/1.1", upstream: "fastcgi://unix:/srv/www/test.namazso.eu/php-fpm.sock:", host: "skinchanger.download"
2017/04/22 21:30:31 [error] 3941#3941: *5 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.68.226.86, server: ~^(?<domain>.+)$, request: "GET /nonexistent.php HTTP/1.1", upstream: "fastcgi://unix:/srv/www/namazso.eu/php-fpm.sock:", host: "namazso.eu"

I only have these servers, with the mentioned being the default:

server_name ~^(www\.)(?<domain>.+)$;
server_name ~^(?<domain>.+)$;
server_name test.namazso.eu;

Change History (3)

comment:1 by Maxim Dounin, 3 years ago

Please show listen directives from the server blocks in question.

Note that "default server" is a property of a server regarding to a listening socket, and not something global. See How nginx processes a request for more details.

comment:2 by namazso@…, 3 years ago

Oops, sorry, it turned out that it was a result of a misconfiguration. the regex only listened on 443, which is the only place it is supposed to get requests at all, but

  • cloudflare was misconfigured, thus showing https, but requesting http in reality
  • and test.namazso.eu was listening on port 80 too, alone so was default too, so the request didn't fail.

I can't close the ticket, so i'd be grateful if you could do it.

Sorry for bothering, and thank you.

comment:3 by Maxim Dounin, 3 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.