Welcome! Log In Create A New Profile


Multiple wildcard server_name

Daniel L. Miller via nginx
September 05, 2022 03:28PM
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
".example.com", is a special wildcard that basically becomes
"example.com *.example.com". 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 https://maindomain.com$request_uri;

server {
listen 443 ssl http2 default_server;
server_name_in_redirect on;

server_name maindomain.com www.maindomain.com *.maindomain.com;

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

This works for "https://maindomain.com" and "http://maindomain.com".
Also for both protocols for "www.maindomain.com". And - it works for
"www.example1.com" as well as the other alternate domains with a "www"
prefix. But it does not work for just "example1.com" 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 "http://example1.com" (which does not re-direct to
https) or "https://example1.com". And I don't understand why.

nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Multiple wildcard server_name

Daniel L. Miller via nginx September 05, 2022 03:28PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 324
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready