Skip to main content

Trojan Go

VPN Tunnel

Docker Compose

version: "3.6"
services:
trojan-go-nginx:
container_name: "trojan-go-nginx"
image: "nginx:alpine"
networks:
- "trojan-go_default"
restart: "unless-stopped"
volumes:
- "/docker-data/trojan-go/config/nginx/nginx.conf:/etc/nginx/conf.d/default.conf"
trojan-go-server:
container_name: "trojan-go-server"
image: "p4gefau1t/trojan-go"
command: ["trojan-go", "-config", "/etc/trojan/config.json"]
networks:
- "trojan-go_default"
ports:
- "8443:443/tcp"
restart: "unless-stopped"
volumes:
- "/docker-data/trojan-go/config/trojan/config.json:/etc/trojan/config.json"
- "/docker-data/trojan-go/config/trojan/cert.pem:/etc/trojan/cert.pem"
- "/docker-data/trojan-go/config/trojan/private.key:/etc/trojan/private.key"
networks:
trojan-go_default:
external: true
name: "trojan-go_default"

Required Files

nginx.conf

path: /docker-data/trojan-go/config/nginx/nginx.conf

server {
listen 80 default_server;
server_name _;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}

server {
listen 8080 http2;
server_name _;
return 400;
}

config.json

path: /docker-data/trojan-go/config/trojan/config.json

{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 443,
"remote_addr": "trojan-go-nginx",
"remote_port": 80,
"log_level": 2,
"log_file": "",
"password": [
"YOUR_PASSWORD"
],
"disable_http_check": false,
"udp_timeout": 60,
"ssl": {
"verify": true,
"verify_hostname": false,
"cert": "/etc/trojan/cert.pem",
"key": "/etc/trojan/private.key",
"key_password": "",
"cipher": "",
"curves": "",
"prefer_server_cipher": false,
"sni": "YOUR_HOST",
"alpn": [
"h2"
],
"session_ticket": true,
"reuse_session": true,
"plain_http_response": "",
"fallback_addr": "",
"fallback_port": 0,
"fingerprint": "firefox"
},
"tcp": {
"no_delay": true,
"keep_alive": true,
"prefer_ipv4": true
},
"mux": {
"enabled": true,
"concurrency": 64,
"idle_timeout": 60
},
"router": {
"enabled": false,
"bypass": [],
"proxy": [],
"block": [],
"default_policy": "proxy",
"domain_strategy": "as_is",
"geoip": "$PROGRAM_DIR$/geoip.dat",
"geosite": "$PROGRAM_DIR$/geosite.dat"
},
"websocket": {
"enabled": true,
"path": "/websocket",
"host": "YOUR_HOST"
},
"shadowsocks": {
"enabled": false,
"method": "AES-128-GCM",
"password": ""
},
"transport_plugin": {
"enabled": false,
"type": "",
"command": "",
"plugin_option": "",
"arg": [],
"env": []
},
"forward_proxy": {
"enabled": false,
"proxy_addr": "",
"proxy_port": 0,
"username": "",
"password": ""
},
"mysql": {
"enabled": false,
"server_addr": "localhost",
"server_port": 3306,
"database": "",
"username": "",
"password": "",
"check_rate": 60
},
"api": {
"enabled": false,
"api_addr": "",
"api_port": 0,
"ssl": {
"enabled": false,
"key": "",
"cert": "",
"verify_client": false,
"client_cert": []
}
}
}

Certificate .Pem and .Key File

you can generate by following this instruction: https://blog.uripsub.dev/setup-trojan-go-server/