我最近像往常一样在 Ubuntu Server 22.04 上启动了一个 nginx webserver
。虚拟机管理程序是 VMware Workstation 16.2.4。当我打开网站时,http://192.168.0.213
我可以看到默认的 nginx 页面。但是如果我尝试使用我的域名,example.com
页面将无法找到……我在我的主机和其他虚拟机上使用 进行了尝试curl
。结果是一样的。我甚至无法从 中打开我的网站webserver
!命令nginx -t
输出成功。
obfuscateduser@dnsserver:~$ curl http://example.com
curl: (7) Failed to connect to example.com port 80 after 0 ms: Connection refused
obfuscateduser@webserver:~$ curl http://example.com
curl: (7) Failed to connect to example.com port 80 after 1 ms: Connection refused
/etc/nginx/sites-available/example.com
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
}
/var/www/example.com/html/index.html
<html>
<head>
<title>Welcome to EXAMPLE.COM!</title>
</head>
<body>
<h1>Success! The your_domain server block is working!</h1>
</body>
</html>
权限
obfuscateduser@webserver:~$ ll /var/www/example.com/html/
total 12
drwxr-xr-x 2 obfuscateduser obfuscateduser 4096 Jan 12 12:00 ./
drwxr-xr-x 3 root root 4096 Jan 11 17:19 ../
-rw-rw-r-- 1 obfuscateduser obfuscateduser 172 Jan 12 11:39 index.html
防火墙输出
Status: active
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
OpenSSH ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
我应该关闭防火墙吗?还是应该在 DNS 区域文件中添加特殊条目?我可以在example.com
文件中添加其他记录吗?