sudo apt-get install trojan
配置文件路径: /etc/trojan/config.json
local_port
: 服务端监听端口,默认443
password
: 密码设置
ssl.cert
: SSL证书
ssl.key
: SSL证书私钥
{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 443,
"remote_addr": "127.0.0.1",
"remote_port": 80,
"password": [
"password"
],
"log_level": 1,
"ssl": {
"cert":"/path/to/cert",
"key": "/path/to/key",
"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": ""
}
}
用systemd
运行Trojan服务trojan.service
[Unit]
Description=trojan-service
[Service]
ExecStart=/usr/bin/trojan /etc/trojan/config.json
Restart=on-failure
RestartSec=60
SyslogIdentifier=trojan-service
User=root
[Install]
WantedBy=multi-user.target
下载链接: https://github.com/yichengchen/clashX/releases
创建节点配置文件: $HOME/.config/sample.yaml
proxies.server
: Trojan服务域名
proxies.port
: Trojan服务端口号
proxies.password
: Trojan服务密码
mixed-port: 7890
socks-port: 7891
port: 7892
external-controller: 127.0.0.1:9090
allow-lan: false
mode: rule
log-level: warning
proxies:
- name: sample
type: trojan
server: sample.com
port: 443
password: "password"
udp: true
alpn:
- http/1.1
proxy-groups:
rules:
- 'DOMAIN-KEYWORD,google,sample'
- 'DOMAIN-KEYWORD,gstatic,sample'
- 'DOMAIN-KEYWORD,youtube,sample'
- 'DOMAIN-KEYWORD,github,sample'
- 'DOMAIN-SUFFIX,ytimg.com,sample'
- 'DOMAIN-SUFFIX,openai.com,sample'
- 'DOMAIN-SUFFIX,microsoft.com,sample'