【发布时间】:2017-04-05 07:21:01
【问题描述】:
我在数字海洋水滴(虚拟专用服务器)上使用this tutorial成功创建了2个服务器块。
我尝试使用相同的方法再创建两个,但是当我访问 server_name 中列出的域(即 example.com)时,我只是得到一个白屏。
我已经重启了 nginx,并重启了我的服务器。
我应该如何测试我的配置是否正常工作?
这是来自 /etc/nginx/sites-available 的“example.com”配置。它是符号链接到 /etc/nginx/sites-enabled
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;
server_name example.com www.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
这是我的 /var/www/example.com/html/index.html
<html>
<head>
<title>Welcome to example.com</title>
</head>
<body style="background:#444444;">
<h1>Success. The example.com server block is working!</h1>
</body>
</html>
使用 DNS 查找工具,它显示访问我的域会返回我服务器的 IP 地址。但是当我wget example.com时,下载的index.html文件来自域名注册商,而不是我的/var/www/example.com/html/index.html这只是DNS传播速度慢吗?
【问题讨论】:
-
您能否对“DNS 说 IP 地址正在访问我的服务器...”这句话做一些澄清,您的期望是什么?你在观察什么?
-
更新:使用DNS查找工具,显示访问我的域返回我服务器的IP地址。
-
如果有人访问您的服务器,他们已经拥有您的 IP 地址。这就是 DNS 的工作原理。我错过了什么吗?
-
我有 4 个域指向我的服务器并配置了 nginx 服务器块(虚拟主机)。我的两个域,完美运行。最新的 2 只显示一个白页,而不是我想显示的 index.html 文件。谢谢
标签: nginx virtualhost digital-ocean ubuntu-16.04