Debian 下测试
安装依赖
apt update && apt install jq curl
获取版本 以及下载链接
VERSION=$(curl -sL https://api.github.com/repos/SagerNet/sing-box/releases/latest | jq -r ".tag_name" | sed 's/^v//')
URL=https://github.com/SagerNet/sing-box/releases/download/v$VERSION/sing-box-$VERSION-linux-amd64.tar.gz
下载二进制压缩包
curl -sSfL $URL -o /tmp/sing-box-$VERSION-linux-amd64.tar.gz
解压
tar -xzf /tmp/sing-box-$VERSION-linux-amd64.tar.gz -C /tmp
mv /tmp/sing-box-$VERSION-linux-amd64/sing-box /usr/local/bin
rm -rf /tmp/sing-box*
创建systemd service
vi /lib/systemd/system/sing-box.service
[Unit]
Description=sing-box service
Documentation=https://sing-box.sagernet.org
After=network.target nss-lookup.target network-online.target
[Service]
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
ExecStart=/usr/local/bin/sing-box -D /var/lib/sing-box -C /etc/sing-box run
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=10s
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
服务端 配置
vi /etc/sing-box/config.json
{
"inbounds": [
{
"type": "hysteria2",
"listen": "::",
"listen_port": 8080,
"up_mbps": 100,
"down_mbps": 100,
"users": [
{
"name": "sekai",
"password": "<password>"
}
],
"tls": {
"enabled": true,
"server_name": "example.org",
"acme": {
"domain": "example.org",
"email": "admin@example.org",
"dns01_challenge": {
"provider": "cloudflare",
"api_token": "my_token"
}
}
}
}
]
}
启动 运行 查看
systemctl enable sing-box.service
systemctl start sing-box
systemctl status sing-box