为什么第二次使用通配符意符;服务器名称;破坏我的nginx配置

为什么第二次使用通配符意符;服务器名称;破坏我的nginx配置,nginx,wildcard,server-name,Nginx,Wildcard,Server Name,此配置按预期正常工作: server { listen 80; server_name www.domain1.com domain1.com; access_log /srv/www/domain1.com/logs/access.log; location / { root /srv/www/domain1.com/public_ht

此配置按预期正常工作:

    server {
            listen       80;
            server_name  www.domain1.com domain1.com;

            access_log  /srv/www/domain1.com/logs/access.log;

            location / {
                root   /srv/www/domain1.com/public_html;
                index  index.html index.htm;


    }
    }
    server {
            listen       80;
            server_name  domain2.com www.domain2.com;

            access_log  /srv/www/domain2.com/logs/access.log;

            location / {
                root   /srv/www/domain2.com/public_html;
                index  index.html index.htm;


    }
    }
此配置在访问以下内容时显示domain1中的内容:

我觉得在这两种情况下我都正确地遵循了规则


在示例2中,使用通配符会导致什么意外行为?

*。domain2.com
domain2.com
不匹配。做:

server_name  domain2.com *.domain2.com;

如果希望站点显示为,请删除星号。这意味着您需要有
server\u name.domain1.com
服务器名称.domain2.com
server_name  domain2.com *.domain2.com;