trojan-gfw on freebsd

Everyone who have installed trojan-gfw on webpage
trojan-gfw

knows that you should install trojan-gfw server side in vps server and trojan-gfw client side in local os.
Install trojna-gfw server in vps server this way:

Prepare domain name :

bind a domain name with vps_ip

Install tools:
sudo apt install trojan apache2
sudo apt install gnutls-bin gnutls-doc

Create model file.
vim ca.tmpl
cn = "domain.com"
organization = "ff"
serial = 1
expiration_days = 3650
ca
signing_key
cert_signing_key
crl_signing_key

vim server.tmpl
cn = "domain.com"
organization = "ff"
expiration_days = 3650
signing_key
encryption_key
tls_www_server

Create and put the certification file and key.

certtool --generate-privkey --outfile ca-key.pem
certtool --generate-privkey --outfile server-key.pem
certtool --generate-certificate --load-privkey server-key.pem --load-ca-certificate ca-cert.pem \
--load-ca-privkey ca-key.pem --template server.tmpl \
--outfile server-cert.pem
sudo cp server-cert.pem /etc/trojan
sudo cp server-key.pem /etc/trojan

Set configuration :
sudo vim /etc/trojan/config.json
{
"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": "/etc/trojan/server-cert.pem",
"key": "/etc/trojan/server-key.pem",
"key_password": "",
"cipher": "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS",
"prefer_server_cipher": true,
"alpn": [
"http/1.1"
],
"reuse_session": true,
"session_timeout": 300,
"curves": "",
"sigalgs": "",
"dhparam": ""
}
}
Create trojan service on server:
sudo vim /etc/systemd/system/trojan.service
[Unit]
Description=trojan
Documentation=https://trojan-gfw.github.io/trojan/config https://trojan-gfw.github.io/trojan/
After=network.target network-online.target nss-lookup.target

[Service]
Type=simple
StandardError=journal
User=trojan
ExecStart="/usr/bin/trojan" "/etc/trojan/config.json"
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=51200
Restart=no

[Install]
WantedBy=multi-user.target
Open ports:
sudo ufw allow 443
sudo ufw allow 80
sudo ufw reload
sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/trojan

Install trojna-gfw client in local os:

sudo apt install trojan
#get ca-cert file from vps.
sudo scp root@vps_ip:/root/ca-cert.pem /etc/trojan

sudo vim /etc/trojan/config.json
{
"run_type": "client",
"local_addr": "127.0.0.1",
"local_port": 1080,
"remote_addr": "domain.com",
"remote_port": 443,
"password": [
"password"
],
"log_level": 1,
"ssl": {
"verify": true,
"verify_hostname": true,
"cert": "/etc/trojan/ca-cert.pem",
"cipher": "CBC3-SHA",
"cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
"sni": "vps_ip",
"alpn": [
"h2",
"http/1.1"
],
"reuse_session": true,
"session_ticket": false,
"curves": ""
},
"tcp": {
"no_delay": true,
"keep_alive": true,
"reuse_port": false,
"fast_open": false,
"fast_open_qlen": 20
}
}

sudo vim /etc/systemd/system/trojan.service
[Unit]
Description=trojan
Documentation=https://trojan-gfw.github.io/trojan/config https://trojan-gfw.github.io/trojan/
After=network.target network-online.target nss-lookup.target

[Service]
Type=simple
StandardError=journal
User=trojan
ExecStart="/usr/bin/trojan" "/etc/trojan/config.json"
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=51200
Restart=no

[Install]
WantedBy=multi-user.target

Both trojan server and client installed on debian.
Can someone here write a tutorial to introduce how to install trojan-gfw server side in vps server (runs freebsd) and trojan-gfw client side in local os(runs freebds)?
 
Last edited:
Back
Top