Can't nginx be accessed with a different domain name on the same port? Why doesn't my server_name work?

I have a local nginx environment, but we have many projects that need port 80. However, why do I configure multiple server in Nginx to listen on port 80, and then distinguish it by server_name? when I build multiple .conf files in the nginx configuration, I find that each domain name (the domain name I set to 80 in host) will jump to my first project

. < hr >

etc/hosts the code is as follows

127.0.0.1   dev.demo.com
127.0.0.1   dev.blog.com

nginx profile path

first project nginx configuration

server {

    -sharplisten 80 default_server;
    -sharplisten [::]:80 default_server ipv6only=on;
    listen 80;

    server_name dev.blog.com;
    root /var/www/blog/public;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        -sharpfixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }
return 404;
}

second project configuration

server {

    -sharplisten 80 default_server;
    -sharplisten [::]:80 default_server ipv6only=on;
    listen 80;

    server_name dev.demo.com;
    root /var/www/demo;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        -sharpfixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }
}

the question is, it is normal for me to access dev.blog.com now, but accessing dev.demo.com, will also jump to the project of blog. Moreover, in hosts, all those pointing to 127.0.0.1 will access the blog project. Excuse me, is nginx different from apache, which configures virtual hosts through domain names?

Mar.02,2021

found the reason, mainly because I used vpn, locally and turned off vpn and then I was fine.


Thank you 6666666666666666

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33258-2be84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33258-2be84.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?