# 欢迎使用 nginx！全新安装后

**URL:** <https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409>\
**Category:** Self-hosting\
**Created:** [2020年四月9日 12:41 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409 "2020-04-09T12:41:57Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月9日 12:41 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/1 "2020-04-09T12:41:57Z")

</div>

你好，

我是 Discourse 的新手，在安装过程中遇到了问题。我创建了一台 Ubuntu Server 18.04 虚拟机，然后大致遵循了 [安装说明](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)。

所谓“大致”，是指我没有使用云服务器，而是使用了 Ubuntu Server。我没有手动安装 Docker，而是让 `discourse-setup` 自动为我安装。此外，我尚未配置邮件服务器，但在安装过程中提供了合理的回答。不确定这是否是导致问题的关键。DNS 已正确配置，服务器也分配了静态 IP 地址。

在引导过程结束后，当我访问服务器的完全限定域名（FQDN）时，看到的是“Welcome to nginx!”页面，而不是“Congratulations, you installed Discourse!”页面。

此安装仅用于实验室环境，不会对外公开访问。

Marc。

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2020年四月9日 12:47 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/2 "2020-04-09T12:47:36Z")

</div>

服务器上是否安装了 nginx？不应该安装。但 `discourse-setup` 应该能检测到这一点。你确定 DNS 配置正确吗？

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月9日 12:59 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/3 "2020-04-09T12:59:24Z")

</div>

服务器上未安装 Nginx。就 DNS 而言，我已为该服务器配置了 A 记录和 PTR 记录。还有哪些其他要求？

Marc。

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月9日 14:41 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/4 "2020-04-09T14:41:34Z")

</div>

唯一能看到该页面的情况是：你将 DNS 指向了错误的服务器，或者 NGINX 位于容器外部，占用了 80 端口，导致容器无法响应。

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 13:26 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/5 "2020-04-10T13:26:18Z")

</div>

如果我将网络浏览器直接指向服务器的 IP 地址，也会看到 Nginx 欢迎页面。

在通过 SSH 登录到 Ubuntu 服务器后：  
`marc@community:~$ locate nginx`  
`/var/discourse/image/base/install-nginx`  
`marc@community:~$`

此外，在 Ubuntu 服务器上执行：  
`sudo find / -iname "*nginx*"`  
…在 `/var/lib/docker/overlay2` 下找到了大量文件…  
`/var/discourse/image/base/install-nginx`  
`/var/discourse/shared/standalone/letsencrypt/deploy/nginx.sh`  
`/var/discourse/shared/standalone/log/var-log/nginx`

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月10日 13:29 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/6 "2020-04-10T13:29:53Z")

</div>

请展示以下命令的结果：

```
lsof -i:80

```

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 13:31 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/7 "2020-04-10T13:31:15Z")

</div>

命令 `lsof -i:80` 没有输出任何内容。

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月10日 13:31 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/8 "2020-04-10T13:31:34Z")

</div>

那么端口 80 上没有任何程序在监听？

如果 Docker 正在监听 :80 端口（任何成功的安装都会实现这一点，并且容器内的 nginx 需要此条件才能看到内容），您应该会看到类似以下内容：

```
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 890 root 4u IPv6 961922 0t0 TCP *:http (LISTEN)

```

> [@1marc1](#):
>
> 我不确定这是否是导致问题的关键。DNS 配置已就绪，服务器也分配了静态 IP 地址。

如果容器外部未安装 nginx，且 Docker 也未监听该端口，那么您能看到 nginx 欢迎页面的唯一可能就是网络配置有误。

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 13:35 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/9 "2020-04-10T13:35:19Z")

</div>

看起来您是对的。在您的笔记本电脑上对服务器 IP 地址运行 nmap 的输出结果：

Starting Nmap 7.01 ( [https://nmap.org](https://nmap.org) ) at 2020-04-10 23:34 AEST  
Nmap scan report for [community.aureus-group-sb.com](http://community.aureus-group-sb.com) (192.168.12.35)  
Host is up (0.0010s latency).  
Not shown: 999 closed ports  
PORT STATE SERVICE  
22/tcp open ssh  
MAC Address: 0C:8B:FD:CD:AF:EB (Intel Corporate)

Nmap done: 1 IP address (1 host up) scanned in 1.74 seconds

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月10日 13:38 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/10 "2020-04-10T13:38:49Z")

</div>

请记住，网络问题可能包括但不限于：

- 虚拟机上的策略阻止了访问（如 ufw 或类似工具）
- 虚拟服务器上的策略阻止了访问（网络模式配置不正确）
- 网络策略配置不正确（子网间的访问控制列表 ACL）
- DNS 配置错误

只有当以上情况均不存在时，才可能是 Discourse 本身的问题。您正在遵循标准安装流程，但据您自己所述，您部署的环境绝非标准环境。

如果您的组织可以承担每月 5 美元的费用，从时间成本角度来看，将服务部署到云端，并将云 VPS 防火墙限制为仅向您的环境返回页面，可能更为划算。

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 13:54 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/11 "2020-04-10T13:54:52Z")

</div>

目前，我主要关注的是学习如何搭建这套系统。一旦掌握，我们肯定会考虑托管选项。

关于您列出的网络方面：

- ufw 处于非活动状态，而 iptables 正在运行：我对 Ubuntu 服务器的默认安装未做任何更改。
- 查看 iptables 配置，input 链的策略是接受所有流量，output 链也是如此。forward 链包含一些与 Docker 相关的引用（见下文）。
- 虚拟机的唯一 vNIC 配置为桥接模式——直接连接到物理网络。
- 我工作的笔记本电脑和虚拟机位于同一子网。
- 我不确定 DNS 的具体要求是什么。我尝试查找相关规范，但未能找到明确的文档。就 DNS 而言，我可以通过主机名、FQDN 和 IP 地址 ping 通服务器。我不确定是否还需要配置其他与 DNS 相关的内容。

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月10日 13:58 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/12 "2020-04-10T13:58:10Z")

</div>

VM 与外部世界之间存在哪些网络策略？

如果 git pull 成功，并且您能够运行 `discourse-setup`，那么有什么会阻止它连接到 GitHub 以下载容器内容吗？

如果服务器无法通过公网地址访问，Let’s Encrypt 将会失败，那么您是否修改了 YML 文件以禁用 HTTPS？

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 14:02 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/13 "2020-04-10T14:02:48Z")

</div>

虚拟机可以连接互联网，且访问 GitHub 没有任何限制。在运行 `discourse-setup` 时，我留空了选项 _Let’s Encrypt 账户邮箱？（按 ENTER 跳过）[me@example.com]:_。我没有修改任何 YML 文件。

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年四月10日 14:05 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/14 "2020-04-10T14:05:04Z")

</div>

将该字段留空意味着您将不会收到有关证书问题的警报，但这并不会阻止容器尝试启用 Let’s Encrypt。

好的，我们已经指出了一些较大的问题，但它们与原始发帖人无关。您的网络中某处有 nginx 在运行并显示一个页面，但根据您的虚拟机测试，您并未安装 nginx，也没有 Docker 在监听。

在弄清楚这是如何发生的之后，第二步将是正确配置 YML 文件。目前，您需要找到该页面的来源。

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 14:06 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/15 "2020-04-10T14:06:43Z")

</div>

我也这么想。让我查一下，看看那个页面是从哪儿来的。

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 14:17 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/16 "2020-04-10T14:17:32Z")

</div>

以下是我所了解的情况。如果我关闭服务器，则无法 ping 通它（IP 地址、主机名和 FQDN）。当我在浏览器中访问该 IP 地址时，Firefox 会显示标准的“无法连接”页面。

因此，我得出结论：不存在 IP 地址冲突。

在启动虚拟机后，我现在也无法通过浏览器连接，再次看到标准的“无法连接”页面。此行为现在与 `lsof -i:80` 输出所预期的结果一致。

---

<div class="post-metadata">

**Author:** ![1marc1](https://avatars.discourse-cdn.com/v4/letter/1/bbe5ce/32.png) [@1marc1](https://meta.discourse.org/u/1marc1)\
**Post date:** [2020年四月10日 14:30 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/17 "2020-04-10T14:30:43Z")

</div>

我通过 `docker exec -it <cont.id> /bin/bash` 进入容器内部，并检查了 `ps aux` 的输出。其中包含以下行：

`root 2030 0.2 0.0 2160 1328 ? Ss 14:10 0:01 runsv nginx`

因此看起来 nginx 正在容器内运行，但 `nsenter -t 1446 -n netstat -plnt` 的输出显示：

```plaintext
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name    
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 3606/unicorn master 
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 3590/postmaster     
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 3591/redis-server * 
tcp6 0 0 :::5432 :::* LISTEN 3590/postmaster     
tcp6 0 0 :::6379 :::* LISTEN 3591/redis-server *

```

这是否表明该容器没有在端口 80 和 443 上监听？

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [2020年四月22日 19:41 UTC](https://meta.discourse.org/t/welcome-to-nginx-after-fresh-installation/147409/18 "2020-04-22T19:41:22Z")

</div>

帖子已拆分到新主题：[显示“欢迎使用 nginx”而非 Discourse](https://meta.discourse.org/t/getting-welcome-to-nginx-instead-of-discourse/148900)
