在我的DigitalOcean液滴中,我正尝试使用我的NginX在同一个液滴上托pipe多个网站。 我可以使用或不使用default_server标记访问test.domain1.com和domain1.com 。 但是,访问domain2.com只是在浏览器中显示domain1.com (带有default_server标记的服务器块)的内容,而不会将 url转发到domain1.com 。 我检查了我的configuration错字,但找不到一个。 其次,access.log和error.log都没有任何问题。
我的液滴的主机名是domain1.com。 我已经创build了2个DNS条目 :1个用于domain1.com,另一个用于domain2.com。 两者都具有相同的A和CNAMElogging。
@ A ip.add.re.ss www CNAME @ * CNAME @
我的configuration是:
/etc/nginx/nginx.conf:
http://pastebin.com/AWf5EM66
/etc/nginx/global/wordpress.conf:
http://pastebin.com/Uc9KSqhh
/etc/nginx/global/restrictions.conf:
http://pastebin.com/cLfMv6jC
/etc/nginx/sites-available/sites.conf:
server { listen 80; listen [::]:80; root /usr/share/nginx/html/domain1_test; index index.php index.html index.htm; server_name test.domain1.com; include global/restrictions.conf; include global/wordpress.conf; } server { listen 80; listen [::]:80; root /usr/share/nginx/html/domain2.com; index index.php index.html index.htm; server_name www.domain2.com; include global/restrictions.conf; include global/wordpress.conf; } server { listen 80 default_server; listen [::]:80; root /usr/share/nginx/html/domain1.com; index index.php index.html index.htm; server_name www.domain1.com; include global/restrictions.conf; include global/wordpress.conf; }
任何线索?
这是因为您没有domain2.com服务器作为server_name,只有www.domain2.com。 将domain2.com作为server_name添加到与www.domain2.com相同的服务器,或者为domain2.com创build另一个服务器,使用return将其redirect到www.domain2.com。