Nginx secondary domain name confusion

at the beginning, the above websites are configured as follows. At this time, each website functions normally

server{
    listen 80;
    server_name  www.xx.com xx.com;-sharp httphttps, www
    return 301 https://www.xx.com$request_uri;
}
server {
    listen 443 ssl;
    server_name www.xx.com;
}
server {
    listen 443 ssl;
    server_name api.xx.com;
}
server {
    listen 443 ssl;
    server_name admin.xx.com;
}

when I added the following sites one day, the problem came

server {
    listen 443 ssl;
    server_name bt.xx.com;
}

when visiting bt.xx.com , the result visits admin.xx.com
turns off admin.xx.com , visits bt.xx.com the result accesses www.xx.com
turns off everything else, and visits bt.xx.com results are normal
this problem has been encountered before, but it is inexplicably better. Solve

< hr >

found another problem
close www.xx.com , visit www.xx.com , the result is admin.xx.com
close www.xx.com and admin.xx.com , visit www.xx.com result is api.xx.com
seems to close www.xx.com .

May.30,2021

nginx configuration file caused by not adding a semicolon

;

I guessed. The same problem happened to a friend before.


  1. when accessing an unconfigured hostname, nginx looks for it in the following order:

    1. default_server in this socket ;
    2. server_name _ in this socket;
    3. the first server block sorted by configuration file in this socket
  2. so, if you close some domain names and then access this domain name, you will match
  3. according to point 1.
  4. should not have the problem of bt.xx.com . The reason may be that there is no reload, configured to access the wrong port and so on.
  5. When
  6. encounters this kind of problem, just look at access_log or debug_log .
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-1e58740-45490.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-1e58740-45490.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?