我在数字海洋小滴(虚拟专用服务器)上使用this tutorial成功创建了2个服务器块。
我尝试使用相同的方法再创建两个,但是当我访问server_name(即example.com)中列出的域时,我只是得到一个白色屏幕。
我重新启动了nginx,并重启了我的服务器。
我应该如何测试我的配置是否有效?
这是我的" example.com"来自/ etc / nginx / sites-available的配置。它与/ etc / nginx / sites-enabled
进行sym链接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传播速度慢吗?
答案 0 :(得分:1)
我想我现在看到了。 DNS测试站点与您使用的DNS服务器之间的DNS推广可能有所不同。但是,还有其他方法可以测试。
文件位置如下:
public CompletableFuture<Response> fetchProductList() {
CompletableFuture<Response> finalResponse = new CompletableFuture<>();
CompletableFuture<Response> cacheCheck = //...
// First, see if we have a cached copy
cacheCheck.whenComplete((response, throwable) -> {
if (throwable == null) {
// Cache hit. Return the cached response
finalResponse.complete(response);
} else {
// Cache miss. Call Amazon
callAmazon(finalResponse);
}
});
return finalResponse;
}
private void callAmazon(CompletableFuture<Response> finalResponse) {
CompletableFuture<Response> amazonApi = //...
amazonApi.whenComplete((response, throwable) -> {
// Copy the state to the `finalResponse`
if (throwable == null) {
finalResponse.complete(response);
} else {
finalResponse.completeExceptionally(throwable);
}
});
}
您打开文件并为新主机名和IP添加条目。使用linux: /etc/hosts
windows: c:\windows\system32\drivers\etc
作为目标IP并将1.2.3.4
作为主机名的示例:
example.com
现在当你执行#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
1.2.3.4 example.com
或wget
时,它将指向服务器1.2.3.4,而不是进行DNS查找。
您也可以使用telnet手动执行GET请求,并指定您正在测试的不同主机名。以下是连接到Google服务器并指定其他主机名的示例:
curl
注意:你需要在&#34; HOST&#34;之后两次点击[ttucker@localhost tmp]$ telnet 216.58.217.206 80
Trying 216.58.217.206...
Connected to 216.58.217.206.
Escape character is '^]'.
GET / HTTP/1.1
HOST: example.com
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=UTF-8
Content-Length: 1561
Date: Mon, 21 Nov 2016 19:57:18 GMT
....
标题,它正在寻找<enter>
。
答案 1 :(得分:0)
由于我的路由器上设置的DNS名称服务器未更新,但我的手机的名称服务器使用了IPv6,并且已更新,我的VPN已更新,导致我的烦恼。
它无法正常工作。