安装步骤

可以选择在go语言官方下载Linux版本源码

我选择的步骤是:

  1. 安装宝塔面板(8.3.X + 版本)
  2. 网站 -> Go项目 -> SDK版本管理 -> 安装 1.22.4(稳定版)
  3. 设置环境变量, 宝塔需要重启服务器后环境变量才能使用 go version 在命令行中执行 测试环境变量是否有效
  4. Git clone NeXT-Server github 源码 https://github.com/SSPanel-NeXT/NeXT-Server.git 直接下载最新源码
  5. go build -o NeXT-Server git完成后cd到源码根目录进行生成 完成后会在根目录生成一个可执行的文件 NeXT-Server
  6. 复制下源码内的示例配置 release/config/config.yml.example 到根目录 config.yml,NeXT-Server执行默认直接加载根文件下的config.yml文件

以下为设置 Nginx + Trojan 的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Log:
Level: warning # Log level: none, error, warning, info, debug
AccessPath: # /etc/uim-server/access.Log
ErrorPath: # /etc/uim-server/error.log
DnsConfigPath: # /etc/uim-server/dns.json
RouteConfigPath: # /etc/uim-server/route.json
InboundConfigPath: # /etc/uim-server/custom_inbound.json
OutboundConfigPath: # /etc/uim-server/custom_outbound.json
ConnectionConfig:
Handshake: 4 # Handshake time limit, Second
ConnIdle: 30 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second
BufferSize: 64 # The internal cache size of each connection, kB
Nodes:
- PanelType: "sspanel-old" # Panel type: sspanel-old, sspanel-v1(wip)
ApiConfig:
ApiHost: "https://xxxxx.com"
ApiKey: "abcdefg"
NodeID: 1
NodeType: trojan # Node type: vmess, trojan, shadowsocks, shadowsocks2022
Timeout: 30 # Timeout for the api request
SpeedLimit: 0 # Mbps, Local settings will replace remote settings, 0 means disable
DeviceLimit: 0 # Local settings will replace remote settings, 0 means disable
RuleListPath: # /etc/uim-server/rulelist Path to local rulelist file
ControllerConfig:
ListenIP: 127.0.0.1 # IP address you want to listen
SendIP: 0.0.0.0 # IP address you want to send pacakage
UpdatePeriodic: 60 # Time to update the nodeinfo, how many sec.
EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well
DNSType: AsIs # AsIs, UseIP, UseIPv4, UseIPv6, DNS strategy
EnableProxyProtocol: true # Only works for WebSocket and TCP
AutoSpeedLimitConfig:
Limit: 0 # Warned speed. Set to 0 to disable AutoSpeedLimit (mbps)
WarnTimes: 0 # After (WarnTimes) consecutive warnings, the user will be limited. Set to 0 to punish overspeed user immediately.
LimitSpeed: 0 # The speedlimit of a limited user (unit: mbps)
LimitDuration: 0 # How many minutes will the limiting last (unit: minute)
CertConfig:
CertMode: dns # Option about how to get certificate: none, file, http, tls, dns. Choose "none" will forcedly disable the tls config.
CertDomain: "node1.test.com" # Domain to cert
CertFile: /etc/uim-server/cert/node1.test.com.cert # Provided if the CertMode is file
KeyFile: /etc/uim-server/cert/node1.test.com.key
Provider: # alidns # cloudflare # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/
Email: xxx@xxx.com
DNSEnv: # DNS ENV option used by DNS provider
# ALICLOUD_ACCESS_KEY: aaa
# ALICLOUD_SECRET_KEY: bbb
# CF_DNS_API_TOKEN: xxx
  1. 只要 NeXT-Panel 那边设置好可以直接启动测试了 ./NeXT-Server

设置守护进程

通过以下方法,你可以让 NeXT-Server 作为守护进程运行,确保其在后台持续运行并在系统重启后自动启动

方法 1:使用 Systemd 更加容易语义化管理【推荐使用】

如果你使用的是基于 Systemd 的 Linux 发行版(如 Ubuntu、Debian、CentOS 7+),可以创建一个 Systemd 服务来管理 NeXT-Server。

  1. 创建一个名为 next-server.service 的服务文件:

    1
    sudo nano /etc/systemd/system/next-server.service
  2. 将以下内容粘贴到服务文件中

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    [Unit]
    Description=NeXT-Server Service
    After=network.target nss-lookup.target
    Wants=network.target

    [Service]
    User=root
    Group=root
    Type=simple
    LimitAS=infinity
    LimitRSS=infinity
    LimitCORE=infinity
    LimitNOFILE=999999
    WorkingDirectory=/root/NeXT-Server/
    ExecStart=/root/NeXT-Server/NeXT-Server -c /root/NeXT-Server/config.yml
    Restart=on-failure
    RestartSec=10

    [Install]
    WantedBy=multi-user.target
  3. 重新加载 Systemd 配置:

    1
    sudo systemctl daemon-reload
  4. 启动 NeXT-Server 服务:

    1
    sudo systemctl start next-server
  5. 设置开机自启动:

    1
    sudo systemctl enable next-server
  6. 检查服务状态:

    1
    sudo systemctl status next-server