debian搭建trojan
#X-ui面板安装
stty erase ^H
apt update -y
apt install -y curl socat
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
#离线安装命令
cd /root/
rm x-ui/ /usr/local/x-ui/ /usr/bin/x-ui -rf
tar zxvf x-ui-linux-amd64.tar.gz
chmod +x x-ui/x-ui x-ui/bin/xray-linux-* x-ui/x-ui.sh
cp x-ui/x-ui.sh /usr/bin/x-ui
cp -f x-ui/x-ui.service /etc/systemd/system/
mv x-ui/ /usr/local/
systemctl daemon-reload
systemctl enable x-ui
systemctl restart x-ui
#安装trojan
apt-get install trojan
#apt-get --purge remove trojan
#修改trojan服务配置文件,
vim /lib/systemd/system/trojan.service
User=nobody 改为 User=root
#常用命令
systemctl start trojan
systemctl stop trojan
systemctl restart trojan
systemctl enable trojan
systemctl disable trojan
systemctl status trojan
#生成自建证书,复制到trojan目录
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 36500
cp cert.pem key.pem /etc/trojan
#申请证书,复制到trojan目录
ufw allow 80
ufw allow 443
apt install socat
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --register-account -m 邮箱
~/.acme.sh/acme.sh --issue -d 域名 --standalone
cd /root/.acme.sh/域名
cp 域名.key fullchain.cer /etc/trojan
#编辑trojan配置文件,修改端口密码和证书路径,默认使用自建证书
vim /etc/trojan/config.json
{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 9622,
"remote_addr": "127.0.0.1",
"remote_port": 80,
"password": [
"l1icznxqwhD&53J^"
],
"log_level": 1,
"ssl": {
"cert": "/etc/trojan/cert.pem", //fullchain.cer
"key": "/etc/trojan/key.pem", //域名.key
//"sni": "域名",
"key_password": "",
"cipher": "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384",
"cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
"prefer_server_cipher": true,
"alpn": [
"http/1.1"
],
"alpn_port_override": {
"h2": 81
},
"reuse_session": true,
"session_ticket": false,
"session_timeout": 600,
"plain_http_response": "",
"curves": "",
"dhparam": ""
},
"tcp": {
"prefer_ipv4": false,
"no_delay": true,
"keep_alive": true,
"reuse_port": false,
"fast_open": false,
"fast_open_qlen": 20
},
"mysql": {
"enabled": false,
"server_addr": "127.0.0.1",
"server_port": 3306,
"database": "trojan",
"username": "trojan",
"password": "",
"key": "",
"cert": "",
"ca": ""
}
}