diff --git a/lite/__pycache__/proxy_lite.cpython-312.pyc b/lite/__pycache__/proxy_lite.cpython-312.pyc new file mode 100644 index 0000000..71511a3 Binary files /dev/null and b/lite/__pycache__/proxy_lite.cpython-312.pyc differ diff --git a/server_config/README.md b/server_config/README.md index 064c154..aed4893 100644 --- a/server_config/README.md +++ b/server_config/README.md @@ -32,7 +32,7 @@ │ └─► 伪装页面(直接访问/IP访问) │ ├─► sing-box() ──► VLESS+REALITY(vision) - ├─► sing-box() ──► Shadowsocks(aes-256-gcm) + ├─► sing-box() ──► Shadowsocks(2022-blake3-aes-256-gcm) └─► mtg() ──► MTProto(Fake TLS, Telegram 内置代理) ``` @@ -42,12 +42,12 @@ |---|---|---|---| | HTTP 隧道 | nginx | CONNECT + Basic Auth | 浏览器/curl/系统代理,全端口 WebSocket 透传 | | 通用代理 | sing-box | VLESS+REALITY | Shadowrocket/Clash/v2rayN 客户端 | -| 兼容旧客户端 | sing-box | Shadowsocks | Shadowrocket 2.x 等不支持 REALITY 的客户端 | -| Telegram 专用 | mtg | MTProto Fake TLS | Telegram 内置代理,抗封锁 | +| 兼容旧客户端 | sing-box | Shadowsocks | Shadowrocket 2.x 等不支持 REALITY 的客户端 || Telegram 专用 | mtg | MTProto Fake TLS | Telegram 内置代理,抗封锁 | -**核心密钥体系(2026-09 起改为每节点独立):** +**核心密钥体系(2026-09 起全部每节点独立):** - VLESS+REALITY:每节点**独立** UUID、REALITY 密钥对、short_id;SNI 仍全节点统一(用 `<伪装SNI域名>`,选一个高流量、TLS 指纹稳定的知名站点域名) -- Shadowsocks:每节点**独立**密码,方法 `aes-256-gcm` +- Shadowsocks:每节点**独立** PSK,方法 `2022-blake3-aes-256-gcm`(SIP022,抗重放探测) +- nginx CONNECT:每节点**独立** Basic Auth 密码(客户端按节点携带凭据,无兼容性问题) - MTProto:每台**独立 secret**(Fake TLS 类型,fronting 到 `<伪装SNI域名>`) > 独立化的目的:单节点密钥泄漏/被污染时不波及其余节点,且换钥粒度更小。 @@ -136,6 +136,27 @@ sysctl net.ipv4.tcp_mtu_probing # 期望输出: 1 > 只影响命中黑洞的连接,正常连接无感知,可安全全节点开启。 +### 2.5 fail2ban(sshd 爆破防护) + +节点 SSH 暴露在公网,爆破尝试是常态(实测单节点累计 3 万+ 次)。装 fail2ban 护 sshd: + +```bash +apt install -y fail2ban +cat > /etc/fail2ban/jail.d/sshd.local << 'EOF' +[sshd] +enabled = true +backend = systemd +EOF +systemctl enable --now fail2ban +fail2ban-client status sshd # 确认 jail 在跑 +``` + +> - `backend = systemd`:无 `/var/log/auth.log` 的最小化系统(无 rsyslog)必须加这行, +> 否则 fail2ban 启动报 "Have not found any log file for sshd jail"。 +> - LXC 容器也能正常封禁(实测 ban/unban 链路可用)。 +> - 只加 fail2ban、**不动 sshd 认证方式**(root 登录等现状保留)。 +> - 如需同时护 nginx CONNECT 的 401 爆破,可再加 nginx jail(凭据够强时可不做)。 + --- ## 3. 伪装站点页面 @@ -213,14 +234,18 @@ make -j$(nproc) && make install ### 5.2 Basic Auth 凭据 -CONNECT 代理需要 Basic Auth(用户名/密码),生成 htpasswd: +CONNECT 代理需要 Basic Auth(用户名/密码),**每节点独立密码**(客户端配置按节点携带凭据,无兼容性问题)。生成 htpasswd: ```bash apt install -y apache2-utils -htpasswd -bc /etc/nginx/.htpasswd <代理用户名> '<代理密码>' +htpasswd -bc /etc/nginx/.htpasswd <代理用户名> '<本节点独立密码>' chmod 644 /etc/nginx/.htpasswd # worker 以 nobody 运行,必须可读 ``` +> 无 apache2-utils 的机器可用 openssl 生成(sha512-crypt,nginx 同样支持): +> `echo "<用户名>:$(openssl passwd -6 '<密码>')" > /etc/nginx/.htpasswd` +> htpasswd 是**每次请求实时读取**的,改密码无需 reload nginx。 + ### 5.3 nginx.conf 完整配置见 [nginx/nginx.conf](nginx/nginx.conf)。**关键设计**: @@ -257,7 +282,9 @@ install -m 755 sing-box-$SINGBOX_VER-linux-amd64/sing-box /usr/local/bin/sing-bo 完整配置见 [sing-box/config.json](sing-box/config.json)。要点: - **VLESS+REALITY**:每节点独立 UUID/密钥对/short_id,SNI 全节点统一,flow `xtls-rprx-vision`;REALITY handshake server 用 `<伪装SNI域名>:443` -- **Shadowsocks**:`aes-256-gcm` + 每节点独立密码,独立端口(兼容不支持 REALITY 的老客户端) +- **Shadowsocks**:`2022-blake3-aes-256-gcm`(SIP022:会话子密钥 + 抗重放探测,显著优于老 AEAD `aes-256-gcm`)+ 每节点独立 PSK,独立端口(兼容不支持 REALITY 的老客户端) + - **PSK 格式要求**:密码必须是 base64 编码的 32 字节密钥(`openssl rand -base64 32`),不是任意字符串;改错格式 sing-box 启动即报错 + - sing-box / Shadowrocket / mihomo 均支持 2022-blake3 系列 - 无 SOCKS5 inbound(已按需移除;如需可在 inbounds 追加 `type: socks`) ### 6.3 REALITY 密钥生成 @@ -378,6 +405,9 @@ systemctl start nginx # 4. nginx(最后,依赖证书/伪装 sysctl net.ipv4.tcp_congestion_control # => bbr sysctl net.ipv4.tcp_mtu_probing # => 1(PMTUD 黑洞缓解,见 2.4) +# fail2ban +fail2ban-client status sshd # => jail 存在(见 2.5) + # sing-box sing-box check -c /etc/sing-box/config.json systemctl is-active sing-box diff --git a/server_config/sing-box/config.json b/server_config/sing-box/config.json index 0bdc015..37bf6d2 100644 --- a/server_config/sing-box/config.json +++ b/server_config/sing-box/config.json @@ -36,8 +36,8 @@ "tag": "ss-in", "listen": "0.0.0.0", "listen_port": "", - "method": "aes-256-gcm", - "password": "" + "method": "2022-blake3-aes-256-gcm", + "password": "" } ], "outbounds": [