一键开启trojan-go docker

date
Dec 23, 2021
slug
tip-trojan-go-docker
status
Published
summary
小技巧-trojan-go 最简单版本;用于iplc转发的落地系统
tags
tip
type
Post
URL

Problem & Summary

  • 一键开启trojan docker - 可以再用iplc来转发

Solution

服务器端

export DOCKER_NAME='trojan-go'
export DOCKER_PORT=44443
export DOCKER_PASSWORD='YourPassword'
export DOCKER_SNI='your.domain.com'

mkdir -p /data/trojan-go; cd /data/trojan-go
# 对应your.domain.com的ssl - 如果client端到时ignore ssl,这里就无所谓了
cat > ./server.crt <<EOF
-----BEGIN CERTIFICATE-----
MIIEmjCCA4KgAwIBAgIUYzJXQBvpBbmBZIPj4WCeNJL6MG0wDQYJKoZIhvcNAQEL
BQAwgYsxCzAJBgNVBAYTAlVTMRkwFwYDVQQKExBDbG91ZEZsYXJlLCBJbmMuMTQw
MgYDVQQLEytDbG91ZEZsYXJlIE9yaWdpbiBTU0wgQ2VydGlmaWNhdGUgQXV0aG9y
aXR5MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRMwEQYDVQQIEwpDYWxpZm9ybmlh
MB4XDTIxMTEyMDAxNTUwMFoXDTM2MTExNjAxNTUwMFowYjEZMBcGA1UEChMQQ2xv
dWRGbGFyZSwgSW5jLjEdMBsGA1UECxMUQ2xvdWRGbGFyZSBPcmlnaW4gQ0ExJjAk
BgNVBAMTHUNsb3VkRmxhcmUgT3JpZ2luIENlcnRpZmljYXRlMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+TzrczWX2x0UjSgpZKoNO+x9EAqIiI80vOT
nOd/3sklvOKBp6et3jBrU88L4et2i0K8r2FlwxSSzBsysQiqzZiZRk9nB1KddGbH
vbSdXxDNvQSLQRQldWEAgmZFZ7C/To2tLInEJE2jKgaby84ZoTQjsfF8EuE1I8Lo
WPlMZ2lPJ2F6/nvaVukx9ZpAMI3UHsu1oU+tuEWX/w0DB8q7QTzh0Hc4Knjs1bCO
6rMnMTzFoVMRVdae6vz+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THdWDQm
ZuS/cz0audK+mx1ZsRb1Or1VqUpa8zQUWrEMP3+CLxLdvMU3mUX+NSHYEQKBgGOv
ZWkbX1o8KeVfyd+G52t4pLL/R/vRU1d4hN25ADmfXsMqMZ3TX4mSs8OAeLZUSLAl
L+08PwufrFiZ7N/jLsBReSwExlGR3u9vDtrCX3xmK7iA5AKh2aaddZgd0in+bScP
I5pBC7rGL0s6HijJ8Gv1HlPzRGl6oG/I6tssHBtVAoGAYuilLg3TP56dZpnkcP4f
5U9bAtuEb8IkugWHLNePsHwXJy/m7KbQnjhx6+xBKy3QEPDwMuZ7mgtaE5rqVd36
DiVpghTA5QtFcrVqX2YjNsEcZOLoP9ycTYk0ohj7ph827RFSZgQZekUrG68ozgxK
WwVokWrIz/VVf0t/EHVYoAQ=
-----END PRIVATE KEY-----
EOF

cat > ./config.json <<EOF
{
    "run_type": "server",
    "local_addr": "0.0.0.0",
    "local_port": 443,
    "remote_addr": "www.bing.com",
    "remote_port": 80,
    "password": [
        "$DOCKER_PASSWORD"
    ],
    "ssl": {
        "cert": "/data/server.crt",
        "key": "/data/server.key",
        "sni": "$DOCKER_SNI"
    }
}
EOF


docker run \
    -d --name=${DOCKER_NAME} --restart=always \
    -p $DOCKER_PORT:443 \
    -p 7443:443 \
    -p 8443:443 \
    -p 9443:443 \
    -p 10443:443 \
    -p 11443:443 \
    -p 12443:443 \
    -p 13443:443 \
    -p 14443:443 \
    -p 15443:443 \
    -p 16443:443 \
    -p 17443:443 \
    -p 18443:443 \
    -p 19443:443 \
    -p 20443:443 \
    -p 21443:443 \
    -p 22443:443 \
    -p 23443:443 \
    -v $(pwd)/server.crt:/data/server.crt:ro \
    -v $(pwd)/server.key:/data/server.key:ro \
    -v $(pwd):/etc/trojan-go \
    teddysun/trojan-go

docker logs -f ${DOCKER_NAME}
 

客户端

# 这是在clash当中的 - sni必须要填对
- name: "-trojan-go"
  type: trojan
  server: your.domain.com
  port: 44443
  password: YourPassword
  sni: your.domain.com
  skip-cert-verify: true
 
notion image
notion image

© Ying Bun 2021 - 2024