Docker安装请参考: Ubuntu Docker 安装 | 菜鸟教程 (runoob.com)
1、拉取镜像docker pull teddysun/trojan-go
root@proxy:/home# docker pull teddysun/trojan-go
Using default tag: latest
latest: Pulling from teddysun/trojan-go
a0d0a0d46f8b: Pull complete
5547b4fc695e: Pull complete
85b267245be1: Pull complete
a3cf7649d371: Pull complete
Digest: sha256:3e4131a334c708e4ee3da4912ddde023dee79117cc8879b0ba943826f7a6ca11
Status: Downloaded newer image for teddysun/trojan-go:latest
docker.io/teddysun/trojan-go:latest
2、创建配置文件 /etc/trojan-go/config.json
mkdir -p /etc/trojan-go
3、我的配置文件如下
root@proxy:/etc/trojan-go# ll
total 14608
drwxr-xr-x 2 root root 4096 Nov 28 03:18 ./
drwxr-xr-x 100 root root 4096 Nov 28 03:02 ../
-rw-rw-rw- 1 root root 805 Nov 28 03:16 config.json
-rw-rw-rw- 1 root root 9782036 Nov 28 03:07 geoip.dat
-rw-rw-rw- 1 root root 5158562 Nov 28 03:08 geosite.dat
root@proxy:/etc/trojan-go# cat config.json
{
"run_type": "client",
"local_addr": "0.0.0.0",
"local_port": 1080,
"remote_addr": "xxx.xxx.xxx",
"remote_port": 443,
"password": [
"youpasswd"
],
"ssl": {
"verify": false,
"verify_hostname": fasle,
"cert": "",
"sni": "xxx.xxx.xxx"
},
"mux": {
"enabled": false
},
"router": {
"enabled": true,
"bypass": [
"geoip:cn",
"geoip:private",
"geosite:cn",
"geosite:geolocation-cn"
],
"block": [
"geosite:category-ads"
],
"proxy": [
"geosite:geolocation-!cn"
],
"default_policy": "proxy",
"geoip": "/etc/trojan-go/geoip.dat",
"geosite": "/etc/trojan-go/geosite.dat"
}
}
4、启动容器
docker run -d --network host --name trojan-go --restart=always -v /etc/trojan-go:/etc/trojan-go teddysun/trojan-go
5、查看容器docker logs trojan-go
root@laohu:/etc/trojan-go# docker logs trojan-go
[INFO] 2022/11/28 15:09:06 trojan-go v0.10.6 initializing
[INFO] 2022/11/28 15:09:06 adapter listening on tcp/udp: 0.0.0.0:1080
[INFO] 2022/11/28 15:09:06 cert is unspecified, using default ca list
[INFO] 2022/11/28 15:09:06 geoip:cn loaded
[INFO] 2022/11/28 15:09:06 geoip:private loaded
[INFO] 2022/11/28 15:09:06 geosite:geolocation-!cn loaded
[INFO] 2022/11/28 15:09:06 geosite:cn loaded
[INFO] 2022/11/28 15:09:06 geosite:geolocation-cn loaded
[INFO] 2022/11/28 15:09:06 geosite:category-ads loaded
[INFO] 2022/11/28 15:09:06 router client created
6、Egde安装插件SwitchyOmega,设置代理IP
7、新建情景模式,选择自动切换模式
规则列表设置,选择 AutoProxy ,输入规则地址,https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
规则列表使用上面设置好的proxy,默认情景选择直连,这样规则内的地址就会自动走代理访问