# 在 Oracle Cloud 上免费自建（附注意事项）

**URL:** <https://meta.discourse.org/t/self-hosting-for-free-with-caveats-with-oracle-cloud/139184>\
**Category:** Self-hosting\
**Tags:** hosting\
**Created:** [2020年一月20日 12:51 UTC](https://meta.discourse.org/t/self-hosting-for-free-with-caveats-with-oracle-cloud/139184 "2020-01-20T12:51:55Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年五月27日 15:09 UTC](https://meta.discourse.org/t/self-hosting-for-free-with-caveats-with-oracle-cloud/139184/15 "2020-05-27T15:09:33Z")

</div>

默认情况下，您无法安装 Discourse，因为不允许连接到端口 80 和 443。您需要在 **安全列表** （在 Oracle 控制面板中）和 **实例防火墙** （通过 SSH）中同时允许这两个端口。

以下是如何在标准的 Ubuntu 安装中完成此操作（与他们的官方指南略有不同，官方指南使用的是另一个 Linux 镜像）。

### 在 Oracle 面板中：

创建 Ubuntu 实例后，进入 **实例详情** 并点击 **子网链接** ：

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/9/b9717cf2cd35b877f73fcc5e9eddbc5392b14d26.png)

点击安全列表：

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/7/471b4ee58a68418df61fc22868b8a2b916320c4a.png)

点击 **添加入站规则** ，选择 **TCP 协议** ，将源 CIDR 设置为 `0.0.0.0/0`，并将 **目标端口范围** 设置为 `80,443`。  
点击“添加入站规则”进行验证。

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/d/1df4f1e399281dcb5e1412317bc1da9f9c087746.png)

确认规则已添加到安全列表中：

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/b/4ba02d65c2ce47806e68a6b40cbcfd82e3f70e78.png)

### 在通过 SSH 访问的服务器命令行中：

将这些规则添加到 iptables：

```plaintext
iptables -I INPUT 5 -i ens3 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -i ens3 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT

```

该命令会将规则添加到正确的位置。如果您只是将它们追加到现有规则中而不指定行号（5），则无法生效，因为它们会被之前存在的“拒绝所有”规则覆盖。

保存规则，以便重启后仍然有效：

```plaintext
netfilter-persistent save

```

现在您可以安装 Discourse 了！🎉

---

_[View the full topic](https://meta.discourse.org/t/self-hosting-for-free-with-caveats-with-oracle-cloud/139184)._
