ZH
EUR
免费版免费 安装

Red Hat, Rocky, Alma

The commands for AlmaLinux, Rocky Linux, RHEL and Oracle Linux 8 to 10: prerequisites, installer, firewalld, SELinux in enforcing mode, check, upgrade and uninstall.

All ways to install

您安装的是哪个版本

目前公开的是名为 0.3.0-dev 的开发版。名称保持不变:每次发布都会替换上一次,并用构建编号区分两个构建。尚无稳定版:只有在每个系统和每个软件包都完成端到端测试之后,才会发布稳定版。因此本页的命令从 dev 通道安装。开发版可能存在缺陷:在依赖它之前,请先在测试站点上试用。

At a glance

  • AlmaLinux, Rocky Linux, Oracle Linux and RHEL 8, 9 and 10 use the same installer and the same steps. It detects the family in /etc/os-release and refuses a version below 8.
  • Keep SELinux enforcing: the installer labels the binaries, configuration, data and logs, labels ports 9443 and 9444 and turns on the httpd_can_network_connect boolean.
  • firewalld is the default firewall: open 80 and 443, and port 9443 for your admin network only.
  • No subscription is needed for ToutWAF itself, but dnf needs access to BaseOS and AppStream to install the prerequisites; on an isolated host, use the offline procedure.

The commands, step by step

更新系统并安装前置依赖

bash
sudo dnf -y update
sudo dnf -y install curl tar ca-certificates firewalld policycoreutils-python-utils

使用一行命令安装脚本

脚本会下载适合您架构的原生二进制文件,创建专用的非特权用户,并安装经过加固的 systemd 服务 toutwaf-dp(数据平面,端口 80 和 443)与 toutwaf-cp(控制平面与控制台,端口 9443),然后打印首次登录信息。

bash
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh | sudo bash

想先阅读脚本?

先下载并审阅,再运行。推荐用于生产服务器。

bash
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh -o install.sh
less install.sh
sudo bash install.sh

安装程序选项

新安装位于单一的主目录 /var/toutwaf(包含 bin、conf、data 和 logs;可用 --home DIR 或 TOUTWAF_HOME 更改),命令行工具会链接到 /usr/local/bin。较早的安装保留自己的路径(/etc/toutwaf、/var/lib/toutwaf),绝不会被移动。

options
# only let your admin network reach the console (port 9443)
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh | sudo bash -s -- --console-from 203.0.113.0/24

# do not touch the host firewall / choose the installation home
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh | sudo bash -s -- --no-firewall
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh | sudo bash -s -- --home /opt/toutwaf

# name the channel explicitly (the installer of the dev branch already takes the dev channel; no stable version exists yet)
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh | sudo bash -s -- --channel dev

开放防火墙

当 firewalld 或 ufw 处于启用状态时,安装程序默认会开放这些端口:80 和 443,以及控制台端口 9443(可用 --console-from 限制为管理网络)。代理端口 9444 绝不会对公网开放。只有在使用 --no-firewall、使用其他防火墙或想手动操作时才需要下面的命令。

firewalld
sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" port port="9443" protocol="tcp" accept'
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

SELinux

保持 SELinux 为 enforcing 模式。为 ToutWAF 目录设置标签,并确认没有记录 AVC 拒绝。

selinux
getenforce
sudo restorecon -Rv /var/toutwaf
sudo ausearch -m avc -ts recent

管理服务

两个服务都会随系统启动。使用这些命令启动、停止或重启它们。

systemd
sudo systemctl enable --now toutwaf-cp toutwaf-dp
sudo systemctl restart toutwaf-cp toutwaf-dp
sudo systemctl stop toutwaf-dp toutwaf-cp

检查服务

bash
sudo systemctl status toutwaf-cp toutwaf-dp --no-pager
toutwafctl doctor
curl -kI https://127.0.0.1:9443/
curl -s http://127.0.0.1:9101/healthz
sudo journalctl -u toutwaf-dp -u toutwaf-cp -n 50 --no-pager

升级

先备份配置和数据,再重新运行安装程序:它会保留您的设置,如果新版本未能恢复正常会自动回滚。这里显示的是新安装的路径(/var/toutwaf);较早的安装仍使用 /etc/toutwaf 和 /var/lib/toutwaf。您也可以在控制台的“更新”页面中升级。

bash
sudo mkdir -p /var/toutwaf.bak
sudo cp -a /var/toutwaf/conf /var/toutwaf/data /var/toutwaf.bak/
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh | sudo bash -s -- --update --yes
curl -s http://127.0.0.1:9101/healthz

卸载

第一段命令移除服务、二进制文件以及 ToutWAF 添加的防火墙规则,并保留您的数据。第二段还会删除配置、数据和日志。

bash
curl -fsSL https://repo.qu3ntin.com/toutwaf/toutwaf/-/raw/dev/install.sh -o install.sh
sudo bash install.sh --uninstall
purge
sudo bash install.sh --uninstall --purge

What is not verified

We prefer to say it plainly.

  • “Tested” means the full installation passed in a container with systemd; real SELinux enforcement was not exercised, and RHEL was validated on Red Hat UBI images.
  • No stable version exists yet: the public version is the development version 0.3.0-dev.

Other ways to install

Learn more in the documentation