This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#!/usr/bin/env bash
# 可选:配置 UFW 防火墙(仅开放 SSH + HTTP/HTTPS)
# 用法:sudo bash deploy/setup-firewall.sh
set -euo pipefail
if [[ "$(id -u)" -ne 0 ]]; then
echo "请使用 sudo 运行"
exit 1
fi
if ! command -v ufw >/dev/null 2>&1; then
echo "未安装 ufw,跳过"
exit 0
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
ufw status
echo "已开放 22/80/443;MySQL(3306)/Redis(6379)/App(3000) 未对外开放"