November 14, 2021

Setup trojan

Overview

To the trojan connection, you need

  • domain name
  • VPS host
  • a normal HTTP server
  • HTTPs certification
  • trojan server
  • trojan client

Setup

VPS

Buy a VPS with external IP address. I used a ubuntu server.

Domain Name

In Godaddy console panel, set A address for the VPS IP address. Such as host.name.

TLS Credentials

Install certbot in ubuntu

apt install certbot

Run certbot and generate certfication

certbot certonly

Note:

  1. stop http/https server before generate certification
  2. choose standalone mode
  3. the generate certification will be put at /etc/letsencrypt/live/

HTTP Server

apt install nginx

Trojan-Go Server

Download trojan code

git clone https://github.com/p4gefau1t/trojan-go.git

Install go development environment

apt install golang

Build binary

go build -o trojan --tags "full" # go 1.17
mv trojan ~/.local/bin # add ~/.local/bin to your PATH

Prepare trojan configuration

{
    "run_type": "server",
    "local_addr": "0.0.0.0",
    "local_port": 443,
    "remote_addr": "127.0.0.1",
    "remote_port": 80,
    "password": [
        "your_awesome_password"
    ],
    "ssl": {
        "cert": "/etc/letsencrypt/live/host.name/fullchain.pem",
        "key": "/etc/letsencrypt/live/host.name/privkey.pem"
    }
}

Start trojan server

Trojan-Go Client

Prepare Trojan binary (copy from server or generate in local machine)

go build -tags "client" -o trojan-client # go 1.17

Prepare client configuration

{
    "run_type": "client",
    "local_addr": "127.0.0.1",
    "local_port": 1080,
    "remote_addr": "host.name",
    "remote_port": 443,
    "password": [
        "password"
    ]
}

Start trojan-go client

trojan -config config.json