juicity 协议搭建教程

juicity 协议用的人比较少,理论上用人越少协议越稳定,juicity 从 2023 年开始开发,截止目前在 GitHub 仅有 1k star,如果你还没听说过,可以去 GitHub 学习。本文主要介绍如何搭建 juicity 协议 + acme 自动续签 + nft 端口转发。

juicity: https://github.com/juicity/juicity

申请证书

使用 acme.sh 实现证书的自动管理

acme: https://github.com/acmesh-official/acme.sh

搭建 juicity

以 Ubuntu 22 为例

  1. 下载 juicity 二进制文件: https://github.com/juicity/juicity/releases ,不同服务器需要下载的文件各有不同

  2. 赋予二进制文件可执行权限 sudo chmod +x juicity

  3. 生成 UUID: sudo python3 -c "from uuid import uuid4;print(uuid4())"

  4. 编辑配置文件 config.json 。{} 为变量,需要手动补充

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    {
    "listen": ":{端口}",
    "users": {
    "{UUID}": "{连接密码}"
    },
    "certificate": "{证书 crt 文件路径}",
    "private_key": "{证书 key 文件路径}",
    "congestion_control": "bbr",
    "log_level": "info"
    }
  5. 运行服务端: ./juicity run -c config.json ,可以使用 systemd 守护进程

端口跳跃

juicity 基于 udp,所以可能会存在 QoS,我们使用 nftables 实现端口跳跃

  1. 安装 nftables: sudo apt install nftables && sudo systemctl enable nftables

  2. 设置端口跳跃

    编辑 /etc/nftables.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    #!/usr/sbin/nft -f

    flush ruleset

    table inet juicity_porthopping {
    chain prerouting {
    type nat hook prerouting priority dstnat; policy accept;
    iifname "eth0" udp dport 3000-3100 counter redirect to :450 comment "juicity_porthopping"
    }
    }

    eth0 为网卡名称,不同服务器可能不一样;3000-3100 为端口跳跃的范围,建议使用低端口,高端口可能还会被限速;450 为 juicity 端口

  3. 重启 nftables: sudo systemctl restart nftables

客户端

https://github.com/juicity/juicity#client

苹果用户推荐使用 Shadowrocket

生成分享链接

1
./juicity generate-sharelink -c config.json

总结

个人体验下来,感觉延迟很低,但是速度比 hysteria2 慢一点。