Multiple wildcard server_name

Daniel L. Miller dmiller at
Mon Sep 5 19:25:41 UTC 2022

While I'm sure this is documented somewhere - I haven't found exactly 
what I'm looking for. Or I'm just not understanding what I've read.

My understanding is simply prefixing a server name with ".", such as 
"", is a special wildcard that basically becomes 
" *". My current nginx version is 1.20.2.

I have a number of domains that I want to re-direct to a master name. 
And I want http re-directed to https. So I have:

server {
     listen 80 default_server;

     location / {
         return 301$request_uri; 

server {
     listen 443 ssl http2 default_server;
     server_name_in_redirect on;

     server_name *;

Based on the docs, I recently changed by second server block from just 
"" to the explicit matching for faster default 

This works for "" and "". 
Also for both protocols for "". And - it works for 
"" as well as the other alternate domains with a "www" 
prefix. But it does not work for just "" or the other 
domains. It doesn't appear to be DNS - both the base domain and the 
"www" A records point to the same IP. What I'm receiving is a 404 Not 
Found for either "" (which does not re-direct to 
https) or "". And I don't understand why.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list