Skip to main content

sing-box-tproxy

GitHub Actions Workflow Status PyPI - Version PyPI - Version Ask DeepWiki

使用 Ansible 自动部署 SagerNet/sing-box TPROXY 透明代理.

特性

  • 支持三种客户端部署模式: gateway (旁路网关), local (本机代理), mixed (混合代理)
  • 支持多种订阅格式: sing-box 原生格式, SIP002 (Shadowsocks)
  • 支持 sing-box 服务端部署: Shadowsocks, Trojan, Hysteria2, VLESS, TUIC
  • 内置 sing-box-liveness-probe: 定期探活, 超过阈值后自动重启服务

前置要求

  • 目标主机: Debian/Ubuntu Linux
  • Ansible core >= 2.18

快速开始

git clone https://github.com/ak1ra-lab/sing-box-tproxy.git
cd sing-box-tproxy/

# 复制并编辑 inventory
cp inventory/hosts.example.yaml inventory/hosts.yaml
vim inventory/hosts.yaml

# 创建并编辑 group_vars
mkdir -p playbooks/group_vars/sing-box-tproxy
cp roles/sing_box_defaults/defaults/main.yaml playbooks/group_vars/sing-box-tproxy/main.yaml
vim playbooks/group_vars/sing-box-tproxy/main.yaml

# 生成 group_vars patch 文件
./group_vars.sh gen tproxy

# 部署
ansible-playbook playbooks/sing_box_tproxy.yaml -v

详细部署指南:

项目结构

sing-box-tproxy/
├── src/sing_box_config/     # Python 配置生成工具 (sing-box-config / sing-box-liveness-probe)
├── playbooks/               # Ansible playbooks
│   ├── group_vars/          # 各 inventory 组的公共变量
│   ├── host_vars/           # 主机级别的变量覆盖
│   ├── sing_box_tproxy.yaml # 部署 sing-box 透明代理
│   ├── sing_box_server.yaml # 部署 sing-box 服务端
│   └── sing_box_reset.yaml  # 重置 (撤销) sing-box 部署
├── roles/                   # Ansible 角色
│   ├── sing_box_defaults/   # 所有变量的默认值 (单一数据源)
│   ├── sing_box_validation/ # 校验 Ansible 变量的合法性
│   ├── sing_box_install/    # 通过 SagerNet APT 仓库安装 sing-box
│   ├── sing_box_config/     # 安装 sing-box-config 并配置定时更新
│   ├── sing_box_tproxy/     # 配置 nftables 与路由策略 (透明代理)
│   ├── sing_box_server/     # 生成服务端配置文件及客户端出站配置
│   └── sing_box_reset/      # 撤销 tproxy / server 部署
├── config/                  # 本地生成的配置文件
│   └── client_outbounds/    # sing_box_server 生成的客户端出站文件
├── inventory/               # Ansible inventory
│   └── hosts.yaml           # 目标主机列表
└── docs/                    # 文档
    ├── deploy-tproxy.md     # 透明代理 (tproxy) 部署指南
    ├── deploy-server.md     # 服务端 (server) 部署指南
    ├── reset.md             # 重置 sing-box 部署
    ├── architecture.md      # 架构设计, 透明代理原理, fwmark 与 nftables 详解
    └── ansible_vars.md      # 所有 Ansible 变量说明

License

MIT License. See LICENSE file for details.

参考资料

Metadata

Release files for sing-box-config 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sing-box-config 0.10.0
File Size Uploaded
sing_box_config-0.10.0.tar.gz 159.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sing-box-config 0.10.0
File Interpreter ABI Platform
sing_box_config-0.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 181.5 kB

Release files / sing_box_config-0.10.0.tar.gz

Download URL sing_box_config-0.10.0.tar.gz
Size 159.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b20bb5296a5470eb9fe2cc571617275e0d51c0205b7f84496f90bbae58281238
BLAKE2b-256 checksum
How to use checksums
699caa733e985700a1b5cd74fd97eff8cd435547c0f8d3e7434c912cf8c6352a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / sing_box_config-0.10.0-py3-none-any.whl

Download URL sing_box_config-0.10.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4df66f9fec48ff25adb579882c4fec986ef71551463a215918bc1e8831ab652
BLAKE2b-256 checksum
How to use checksums
15dee02049601dfaca8f5344d7798ab93d3e3d99bc8c5f99b18bf8fe6fa33404
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page