# UFW也会限制Discourse吗？

**URL:** <https://meta.discourse.org/t/will-ufw-limit-discourse-too/231873>\
**Category:** Self-hosting\
**Created:** [2022年七月4日 12:08 UTC](https://meta.discourse.org/t/will-ufw-limit-discourse-too/231873 "2022-07-04T12:08:17Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)\
**Post date:** [2022年七月11日 03:34 UTC](https://meta.discourse.org/t/will-ufw-limit-discourse-too/231873/19 "2022-07-11T03:34:11Z")

</div>

实际上，过了一会儿我才弄明白，并编写了这个 bash 脚本来完成 Discourse 安装的任务。

它会重置你的防火墙，安装 [ufw-docker-util](https://github.com/chaifeng/ufw-docker#ufw-docker-util)（该工具会编辑 after.rules），然后将端口 443 和 80 添加到你的允许列表中。搞定。

它还允许来自任何 IP 的端口 22，以确保你不会被锁定。在一切正常工作后，再次保护端口 22。

> **[auto-docker-ufw/discourse at main · MarcRez33/auto-docker-ufw](https://github.com/MarcRez33/auto-docker-ufw/tree/main/discourse)**
>
> Contribute to MarcRez33/auto-docker-ufw development by creating an account on GitHub.

> 编辑：脚本确实有效，但在使用它之后重建 Discourse 会失败：`fatal: unable to access 'https://github.com/discourse/discourse.git/': Could not resolve host: github.com` - 因此，除非你知道如何解决这个问题，否则请勿使用该脚本。

> 编辑 2：在 Ubuntu 上有效，但在 CentOS 上无效！

---

_[View the full topic](https://meta.discourse.org/t/will-ufw-limit-discourse-too/231873)._
